Guest User

Untitled

a guest
Jul 24th, 2018
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. error_reporting(E_ALL);
  2. //error_reporting(E_STRICT);
  3.  
  4. date_default_timezone_set('America/Toronto');
  5.  
  6. require_once('class.phpmailer.php');
  7. include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  8.  
  9. try {
  10.  
  11. $mail = new PHPMailer();
  12.  
  13. $body = file_get_contents('contents.html');
  14. $body = eregi_replace("[]",'',$body);
  15. $mail->IsSMTP(); // telling the class to use SMTP
  16. //$mail->Host = "mail.yourdomain.com"; // SMTP server
  17. $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
  18. // 1 = errors and messages
  19. // 2 = messages only
  20. $mail->SMTPAuth = true; // enable SMTP authentication
  21. $mail->SMTPSecure = "tls";
  22. $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
  23. $mail->Port = 587; // set the SMTP port for the GMAIL server
  24. $mail->Username = "email@gmail.com"; // GMAIL username
  25. $mail->Password = "password"; // GMAIL password
  26.  
  27. $mail->SetFrom('email@gmail.com', 'Daud');
  28.  
  29. //$mail->AddReplyTo("email@gmail.com","Daud");
  30.  
  31. $mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic";
  32.  
  33. $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  34.  
  35. $mail->MsgHTML($body);
  36.  
  37. $address = "toemailaddress@gmail.com";
  38. $mail->AddAddress($address, "John Doe");
  39.  
  40. $mail->AddAttachment("images/phpmailer.gif"); // attachment
  41. $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
  42. echo " <br/>Start Mail Send<br/>";
  43.  
  44. if(!$mail->Send()) {
  45. echo "Mailer Error: " . $mail->ErrorInfo;
  46. } else {
  47. echo "Message sent!";
  48. }
  49. } catch (phpmailerException $e) {
  50. echo $e->errorMessage(); //Pretty error messages from PHPMailer
  51. } catch (Exception $e) {
  52. echo $e->getMessage(); //Boring error messages from anything else!
  53. }
  54. echo " <br/>Mail should be sent by now!<br/>";
  55.  
  56. SMTP -> FROM SERVER:220 mx.google.com ESMTP o17sm126066fal.26
  57. SMTP -> FROM SERVER: 250-mx.google.com at your service, [195.212.29.180] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250 PIPELINING
  58. SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS
Add Comment
Please, Sign In to add comment