Advertisement
Guest User

Untitled

a guest
Sep 5th, 2016
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. $to = 'nobody@whateverdomain.com';
  3. $subject = 'the subject';
  4. $message = 'hello';
  5. $headers = 'From: webmaster@whateverdomain.com' . "rn" .
  6. 'Reply-To: webmaster@whateverdomain.com' . "rn" .
  7. 'X-Mailer: PHP/' . phpversion();
  8. mail($to, $subject, $message, $headers);
  9. ?>
  10.  
  11. <?php
  12. require_once "Mail.php";
  13.  
  14. $from = "Name Surname <sender@yourdomain.com>";
  15. $to = "Name Whatever <recipient@example.com>";
  16. $subject = "Subject!";
  17. $body = "Hi,nnHow are you?";
  18.  
  19. $host = "mail.yourdomain.com";
  20. $username = "smtp_username";
  21. $password = "smtp_password";
  22.  
  23. $headers = array ('From' => $from,
  24. 'To' => $to,
  25. 'Subject' => $subject);
  26. $smtp = Mail::factory('smtp',
  27. array ('host' => $host,
  28. 'auth' => true,
  29. 'username' => $username,
  30. 'password' => $password));
  31.  
  32. $mail = $smtp->send($to, $headers, $body);
  33.  
  34. if (PEAR::isError($mail)) {
  35. echo("<p>" . $mail->getMessage() . "</p>");
  36. } else {
  37. echo("<p>Message successfully sent!</p>");
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement