Guest User

Untitled

a guest
Sep 17th, 2018
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. Sending an email using PHPMailer and GMAIL SMTP
  2. include("phpMailer/class.phpmailer.php"); // path to the PHPMailer class
  3. $mail = new PHPMailer();
  4. $mail->IsSMTP(); // send via SMTP
  5.  
  6. $mail->SMTPAuth = true; // turn on SMTP authentication
  7. $mail->Username = "myUsername"; // SMTP username
  8. $mail->Password = "myPassword"; // SMTP password
  9. $mail->SMTPDebug = 1;
  10. $webmaster_email = "webMasterEmail@gmail.com"; //Reply to this email ID
  11. $email="someone@gmail.com"; // Recipients email ID
  12. $name="SomeonesName"; // Recipient's name
  13. $mail->From = $webmaster_email;
  14. $mail->FromName = "Me";
  15. $mail->AddAddress($email,$name);
  16. $mail->AddReplyTo($webmaster_email,"Webmaster");
  17. $mail->WordWrap = 50; // set word wrap
  18. $mail->IsHTML(true); // send as HTML
  19. $mail->Subject = "This is the subject";
  20. $mail->Body = "Hi,
  21. This is the HTML BODY "; //HTML Body
  22. $mail->AltBody = "This is the body when user views in plain text format"; //Text Body
  23. if(!$mail->Send())
  24. {
  25. echo "Mailer Error: " . $mail->ErrorInfo;
  26. }
  27. else
  28. {
  29. echo "Message has been sent";
  30. }
  31.  
  32. $host = "ssl://smtp.gmail.com";
  33. $port = 465;
  34.  
  35. [PHP_OPENSSL]
  36. extension=php_openssl.dll
Add Comment
Please, Sign In to add comment