mail.phps 1.1 KB

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