Advertisement
Guest User

Untitled

a guest
Sep 13th, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?php
  2. //add to composer.json "phpmailer/phpmailer": "~5.2"
  3.  
  4. require_once 'vendor/autoload.php';
  5. $mail = new PHPMailer();
  6.  
  7. $mail->IsSMTP();
  8. $mail->Mailer = 'smtp';
  9. $mail->SMTPAuth = true;
  10. $mail->Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked
  11. $mail->SMTPSecure = 'tls'; // or 'ssl'
  12. $mail->Port = 587; //465 for ssl
  13.  
  14. $mail->Username = "mahedi2014@gmail.com";
  15. $mail->Password = ""; //your gmail password
  16.  
  17. $mail->IsHTML(true); // if you are going to send HTML formatted emails
  18. $mail->SingleTo = true; // if you want to send a same email one-by-one to multiple users in .
  19.  
  20. $mail->From = "mahedi2014@gmail.com";
  21. $mail->FromName = "Your Name";
  22.  
  23. $mail->addAddress("mahedi201422@gmail.com","User 1");
  24. $mail->addAddress("mahedi2014222@gmail.com","User 2");
  25.  
  26. $mail->addCC("mahedi20141@gmail.com","User 3");
  27. $mail->addBCC("mahedi20142@gmail.com","User 4");
  28.  
  29. $mail->Subject = "Testing PHPMailer with localhost";
  30. $mail->Body = "Hi,<br /><br />This system is working perfectly.";
  31.  
  32. if(!$mail->Send())
  33. echo "Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo;
  34. else
  35. echo "Message has been sent";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement