Advertisement
Guest User

Untitled

a guest
May 28th, 2017
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2. include "vendor/autoload.php";
  3.  
  4.  
  5. $mail = new PHPMailer;
  6.  
  7. //$mail->SMTPDebug = 3; // Enable verbose debug output
  8.  
  9. $mail->isSMTP(); // Set mailer to use SMTP
  10. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  11. $mail->SMTPAuth = true; // Enable SMTP authentication
  12. $mail->Username = 'user@gmail.com'; // SMTP username
  13. $mail->Password = 'xxxx'; // SMTP password
  14. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  15. $mail->Port = 587; // TCP port to connect to
  16.  
  17. $mail->setFrom('from@example.com', 'Mailer');
  18. $mail->addAddress('joe@example.com', 'Joe User'); // Add a recipient
  19. $mail->addAddress('ellen@example.com'); // Name is optional
  20. $mail->addReplyTo('info@example.com', 'Information');
  21. $mail->addCC('cc@example.com');
  22. $mail->addBCC('bcc@example.com');
  23.  
  24. $mail->addAttachment('/home/tutsplanet/file.tar.gz'); // Add attachments
  25. $mail->isHTML(true); // Set email format to HTML
  26.  
  27. $mail->Subject = 'Here comes the the subject';
  28. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  29. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  30.  
  31. if(!$mail->send()) {
  32. echo 'Message could not be sent.';
  33. echo 'Mailer Error: ' . $mail->ErrorInfo;
  34. } else {
  35. echo 'Message has been sent';
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement