Guest User

Untitled

a guest
Mar 21st, 2017
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2.  require_once "Mail.php";
  3.  
  4.  $from = "Sandra Sender <sender@example.com>";
  5.  $to = "Ramona Recipient <recipient@example.com>";
  6.  $subject = "Hi!";
  7.  $body = "Hi,\n\nHow are you?";
  8.  
  9.  $host = "mail.example.com";
  10.  $username = "smtp_username";
  11.  $password = "smtp_password";
  12.  
  13.  $headers = array ('From' => $from,
  14.    'To' => $to,
  15.    'Subject' => $subject);
  16.  $smtp = Mail::factory('smtp',
  17.    array ('host' => $host,
  18.      'auth' => true,
  19.      'username' => $username,
  20.      'password' => $password));
  21.  
  22.  $mail = $smtp->send($to, $headers, $body);
  23.  
  24.  if (PEAR::isError($mail)) {
  25.    echo("<p>" . $mail->getMessage() . "</p>");
  26.   } else {
  27.    echo("<p>Message successfully sent!</p>");
  28.   }
  29.  ?>
Add Comment
Please, Sign In to add comment