Advertisement
Guest User

Untitled

a guest
May 24th, 2017
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?
  2. include('Mail.php');
  3. include('Mail/mime.php');
  4. // Constructing the email
  5. $sender = "shi <shichuanr@msn.com>";
  6. $recipient = "Leigh <shichuanr@gmail.com>";
  7. $subject = "Test Email";
  8. $text = 'This is a text message.';
  9. $html = '<html><body><p>This is a html message</p></body></html>';
  10. $crlf = "\n";
  11. $headers = array(
  12. 'From' => $sender,
  13. 'Return-Path' => $sender,
  14. 'Subject' => $subject
  15. );
  16. // Creating the Mime message
  17. $mime = new Mail_mime($crlf);
  18. // Setting the body of the email
  19. $mime->setTXTBody($text);
  20. $mime->setHTMLBody($html);
  21. // Set body and headers ready for base mail class
  22. $body = $mime->get();
  23. $headers = $mime->headers($headers);
  24. // SMTP params
  25. $smtp_params["host"] = "localhost"; // SMTP host
  26. $smtp_params["port"] = "25"; // SMTP Port (usually 25)
  27. // Sending the email using smtp
  28. $mail =&amp; Mail::factory("smtp", $smtp_params);
  29. $result = $mail->send($recipient, $headers, $body);
  30. if($result == 1)
  31. {
  32. echo("Your message has been sent!");
  33. }
  34. else
  35. {
  36. echo("Your message was not sent: " . $result);
  37. }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement