Advertisement
Guest User

Untitled

a guest
Sep 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <?php
  2. use PHPMailer\PHPMailer\PHPMailer;
  3. use PHPMailer\PHPMailer\Exception;
  4.  
  5. require 'src/Exception.php';
  6. require 'src/PHPMailer.php';
  7. require 'src/SMTP.php';
  8.  
  9.  
  10. $mail = new PHPMailer(true); // Passing `true` enables exceptions
  11. try {
  12. //Server settings
  13. $mail->SMTPDebug = 2; // Enable verbose debug output
  14. $mail->isSMTP(); // Set mailer to use SMTP
  15. $mail->Host = 'smtp.brokenvector.com'; // Specify main and backup SMTP servers
  16. $mail->SMTPAuth = true; // Enable SMTP authentication
  17. $mail->Username = 'noreply@brokenvector.com'; // SMTP username
  18. $mail->Password = '*******'; // SMTP password
  19. $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
  20. $mail->Port = 465; // TCP port to connect to
  21.  
  22. //Recipients
  23. $mail->setFrom('noreply@brokenvector.com', 'Mailer');
  24. $mail->addAddress('michael@brokenvector.com', 'Joe User'); // Add a recipient
  25.  
  26.  
  27. //Content
  28. $mail->isHTML(true); // Set email format to HTML
  29. $mail->Subject = 'Here is the subject';
  30. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  31. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  32.  
  33. $mail->send();
  34. echo 'Message has been sent';
  35. } catch (Exception $e) {
  36. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  37. }
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement