test_mail_basic.php 1.0 KB

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