test_smtp_basic_no_auth.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <html>
  2. <head>
  3. <title>PHPMailer - SMTP basic test with no authentication</title>
  4. </head>
  5. <body>
  6. <?php
  7. //error_reporting(E_ALL);
  8. error_reporting(E_STRICT);
  9. date_default_timezone_set('America/Toronto');
  10. require_once('../class.phpmailer.php');
  11. //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  12. $mail = new PHPMailer();
  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->SetFrom('name@yourdomain.com', 'First Last');
  21. $mail->AddReplyTo("name@yourdomain.com","First Last");
  22. $mail->Subject = "PHPMailer Test Subject via smtp, basic with no authentication";
  23. $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  24. $mail->MsgHTML($body);
  25. $address = "whoto@otherdomain.com";
  26. $mail->AddAddress($address, "John Doe");
  27. $mail->AddAttachment("images/phpmailer.gif"); // attachment
  28. $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
  29. if(!$mail->Send()) {
  30. echo "Mailer Error: " . $mail->ErrorInfo;
  31. } else {
  32. echo "Message sent!";
  33. }
  34. ?>
  35. </body>
  36. </html>