test_sendmail_advanced.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. <html>
  2. <head>
  3. <title>PHPMailer - Sendmail advanced test</title>
  4. </head>
  5. <body>
  6. <?php
  7. require_once('../class.phpmailer.php');
  8. $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
  9. $mail->IsSendmail(); // telling the class to use SendMail transport
  10. try {
  11. $mail->AddReplyTo('name@yourdomain.com', 'First Last');
  12. $mail->AddAddress('whoto@otherdomain.com', 'John Doe');
  13. $mail->SetFrom('name@yourdomain.com', 'First Last');
  14. $mail->AddReplyTo('name@yourdomain.com', 'First Last');
  15. $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
  16. $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
  17. $mail->MsgHTML(file_get_contents('contents.html'));
  18. $mail->AddAttachment('images/phpmailer.gif'); // attachment
  19. $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
  20. $mail->Send();
  21. echo "Message Sent OK</p>\n";
  22. } catch (phpmailerException $e) {
  23. echo $e->errorMessage(); //Pretty error messages from PHPMailer
  24. } catch (Exception $e) {
  25. echo $e->getMessage(); //Boring error messages from anything else!
  26. }
  27. ?>
  28. </body>
  29. </html>