testemail.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Simple example script using PHPMailer with exceptions enabled
  4. * @package phpmailer
  5. * @version $Id$
  6. */
  7. require '../class.phpmailer.php';
  8. try {
  9. $mail = new PHPMailer(true); //New instance, with exceptions enabled
  10. $body = file_get_contents('contents.html');
  11. $body = preg_replace('/\\\\/','', $body); //Strip backslashes
  12. $mail->IsSMTP(); // tell the class to use SMTP
  13. $mail->SMTPAuth = true; // enable SMTP authentication
  14. $mail->Port = 25; // set the SMTP server port
  15. $mail->Host = "mail.yourdomain.com"; // SMTP server
  16. $mail->Username = "name@domain.com"; // SMTP server username
  17. $mail->Password = "password"; // SMTP server password
  18. $mail->IsSendmail(); // tell the class to use Sendmail
  19. $mail->AddReplyTo("name@domain.com","First Last");
  20. $mail->From = "name@domain.com";
  21. $mail->FromName = "First Last";
  22. $to = "someone@example...com";
  23. $mail->AddAddress($to);
  24. $mail->Subject = "First PHPMailer Message";
  25. $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  26. $mail->WordWrap = 80; // set word wrap
  27. $mail->MsgHTML($body);
  28. $mail->IsHTML(true); // send as HTML
  29. $mail->Send();
  30. echo 'Message has been sent.';
  31. } catch (phpmailerException $e) {
  32. echo $e->errorMessage();
  33. }
  34. ?>