Advertisement
Guest User

Untitled

a guest
Aug 14th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>PHPMailer - SMTP (Gmail) basic test</title>
  4. </head>
  5. <body>
  6.  
  7. <?php
  8.  
  9. //error_reporting(E_ALL);
  10. error_reporting(E_STRICT);
  11.  
  12. date_default_timezone_set('America/Toronto');
  13.  
  14. require_once('../class.phpmailer.php');
  15. //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  16.  
  17. $mail = new PHPMailer();
  18.  
  19. $body = file_get_contents('contents.html');
  20. $body = eregi_replace("[\]",'',$body);
  21.  
  22. $mail->IsSMTP(); // telling the class to use SMTP
  23. $mail->Host = "smtp.gmail.com"; // SMTP server
  24. $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
  25. // 1 = errors and messages
  26. // 2 = messages only
  27. $mail->SMTPAuth = true; // enable SMTP authentication
  28. $mail->SMTPSecure = "ssl"; // sets the prefix to the servier
  29. $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
  30. $mail->Port = 465; // set the SMTP port for the GMAIL server
  31. $mail->Username = "mojEmail@gmail.com"; // GMAIL username
  32. $mail->Password = "*********"; // GMAIL password
  33.  
  34. $mail->SetFrom('mojEmail@gmail.com', 'First Last');
  35.  
  36. $mail->AddReplyTo("mojEmail@gmail.com","First Last");
  37.  
  38. $mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic";
  39.  
  40. $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  41.  
  42. $mail->MsgHTML($body);
  43.  
  44. $address = "mojEmail@gmail.com";
  45. $mail->AddAddress($address, "John Doe");
  46.  
  47. $mail->AddAttachment("images/phpmailer.gif"); // attachment
  48. $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
  49.  
  50. if(!$mail->Send()) {
  51. echo "Mailer Error: " . $mail->ErrorInfo;
  52. } else {
  53. echo "Message sent!";
  54. }
  55.  
  56. ?>
  57.  
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement