Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2018
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. PHP
  2.  
  3. <?php
  4. include( "mta_sdk.php" );
  5. use PHPMailer\PHPMailer\PHPMailer;
  6. use PHPMailer\PHPMailer\Exception;
  7. require 'PHPMailer/src/Exception.php';
  8. require 'PHPMailer/src/PHPMailer.php';
  9. require 'PHPMailer/src/SMTP.php';
  10.  
  11. $mail = new PHPMailer(true); // Passing `true` enables exceptions
  12. try {
  13. //Server settings
  14. $mail->SMTPDebug = 2; // Enable verbose debug output
  15. $mail->isSMTP(); // Set mailer to use SMTP
  16. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  17. $mail->SMTPAuth = true; // Enable SMTP authentication
  18. $mail->Username = 'mtagostown@gmail.com'; // SMTP username
  19. $mail->Password = 'MTAGostown1234'; // SMTP password
  20. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  21. $mail->Port = 587;
  22.  
  23. $mail->SMTPOptions = array(
  24. 'ssl' => array(
  25. 'verify_peer' => false,
  26. 'verify_peer_name' => false,
  27. 'allow_self_signed' => true
  28. )
  29. );
  30.  
  31. // TCP port to connect to
  32.  
  33. $input = mta::getInput();
  34.  
  35. //Recipients
  36. $mail->setFrom('mtagostown@gmail.com', 'MTA Gostown');
  37. $mail->addAddress($input[0], 'Użytkownik'); // Add a recipient
  38. //$mail->addAddress('contact@example.com'); // Name is optional
  39. //$mail->addReplyTo('info@example.com', 'Information');
  40. //$mail->addCC('cc@example.com');
  41. //$mail->addBCC('bcc@example.com');
  42.  
  43. //Attachments
  44. //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  45. //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  46.  
  47. //Content
  48. $mail->isHTML(true); // Set email format to HTML
  49. $mail->Subject = $input[1];
  50. $mail->Body = $input[2];
  51. //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  52.  
  53. $mail->send();
  54. echo 'Message has been sent';
  55. mta::doReturn(true);
  56. } catch (Exception $e) {
  57. echo 'Message could not be sent.';
  58. echo 'Mailer Error: ' . $mail->ErrorInfo;
  59. mta::doReturn(false, 2);
  60. }
  61. ?>
  62.  
  63. LUA
  64.  
  65.  
  66. function sendMail(sendTo, subject, body)
  67. callRemote("localhost/emailSending/mail_sending.php", mailReturns, sendTo, subject, body)
  68. end
  69. addEvent("php:sendMail", true)
  70. addEventHandler("php:sendMail", root, sendMail)
  71.  
  72. function mailReturns(msg, num)
  73. if false then
  74. outputDebugString("E-Mail nie został wysłany.", 2)
  75. else
  76. outputDebugString("E-Mail został pomyślnie wysłany!", num or 3)
  77. end
  78. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement