test_pop_before_smtp_basic.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <html>
  2. <head>
  3. <title>POP before SMTP Test</title>
  4. </head>
  5. <body>
  6. <?php
  7. require_once('../class.phpmailer.php');
  8. require_once('../class.pop3.php'); // required for POP before SMTP
  9. $pop = new POP3();
  10. $pop->Authorise('pop3.yourdomain.com', 110, 30, 'username', 'password', 1);
  11. $mail = new PHPMailer();
  12. $body = file_get_contents('contents.html');
  13. $body = eregi_replace("[\]",'',$body);
  14. $mail->IsSMTP();
  15. $mail->SMTPDebug = 2;
  16. $mail->Host = 'pop3.yourdomain.com';
  17. $mail->SetFrom('name@yourdomain.com', 'First Last');
  18. $mail->AddReplyTo("name@yourdomain.com","First Last");
  19. $mail->Subject = "PHPMailer Test Subject via POP before SMTP, basic";
  20. $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  21. $mail->MsgHTML($body);
  22. $address = "whoto@otherdomain.com";
  23. $mail->AddAddress($address, "John Doe");
  24. $mail->AddAttachment("images/phpmailer.gif"); // attachment
  25. $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
  26. if(!$mail->Send()) {
  27. echo "Mailer Error: " . $mail->ErrorInfo;
  28. } else {
  29. echo "Message sent!";
  30. }
  31. ?>
  32. </body>
  33. </html>