test_sendmail_basic.php 1.1 KB

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