sendmail.phps 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  5. <title>PHPMailer - sendmail test</title>
  6. </head>
  7. <body>
  8. <?php
  9. require '../PHPMailerAutoload.php';
  10. //Create a new PHPMailer instance
  11. $mail = new PHPMailer();
  12. // Set PHPMailer to use the sendmail transport
  13. $mail->isSendmail();
  14. //Set who the message is to be sent from
  15. $mail->setFrom('from@example.com', 'First Last');
  16. //Set an alternative reply-to address
  17. $mail->addReplyTo('replyto@example.com', 'First Last');
  18. //Set who the message is to be sent to
  19. $mail->addAddress('whoto@example.com', 'John Doe');
  20. //Set the subject line
  21. $mail->Subject = 'PHPMailer sendmail test';
  22. //Read an HTML message body from an external file, convert referenced images to embedded,
  23. //convert HTML into a basic plain-text alternative body
  24. $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  25. //Replace the plain text body with one created manually
  26. $mail->AltBody = 'This is a plain-text message body';
  27. //Attach an image file
  28. $mail->addAttachment('images/phpmailer_mini.gif');
  29. //send the message, check for errors
  30. if (!$mail->send()) {
  31. echo "Mailer Error: " . $mail->ErrorInfo;
  32. } else {
  33. echo "Message sent!";
  34. }
  35. ?>
  36. </body>
  37. </html>