Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PHP
- <?php
- include( "mta_sdk.php" );
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require 'PHPMailer/src/Exception.php';
- require 'PHPMailer/src/PHPMailer.php';
- require 'PHPMailer/src/SMTP.php';
- $mail = new PHPMailer(true); // Passing `true` enables exceptions
- try {
- //Server settings
- $mail->SMTPDebug = 2; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'mtagostown@gmail.com'; // SMTP username
- $mail->Password = 'MTAGostown1234'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587;
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- // TCP port to connect to
- $input = mta::getInput();
- //Recipients
- $mail->setFrom('mtagostown@gmail.com', 'MTA Gostown');
- $mail->addAddress($input[0], 'Użytkownik'); // Add a recipient
- //$mail->addAddress('contact@example.com'); // Name is optional
- //$mail->addReplyTo('info@example.com', 'Information');
- //$mail->addCC('cc@example.com');
- //$mail->addBCC('bcc@example.com');
- //Attachments
- //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
- //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = $input[1];
- $mail->Body = $input[2];
- //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- $mail->send();
- echo 'Message has been sent';
- mta::doReturn(true);
- } catch (Exception $e) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- mta::doReturn(false, 2);
- }
- ?>
- LUA
- function sendMail(sendTo, subject, body)
- callRemote("localhost/emailSending/mail_sending.php", mailReturns, sendTo, subject, body)
- end
- addEvent("php:sendMail", true)
- addEventHandler("php:sendMail", root, sendMail)
- function mailReturns(msg, num)
- if false then
- outputDebugString("E-Mail nie został wysłany.", 2)
- else
- outputDebugString("E-Mail został pomyślnie wysłany!", num or 3)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement