Advertisement
Guest User

Send mail pear

a guest
Oct 30th, 2011
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1.   require_once "Mail.php";
  2.   require_once "Mail/mime.php";
  3.  
  4.   $message = new Mail_mime();
  5.   $html = "Hello <strong>world</strong> !";
  6.  
  7.   $message->setHTMLBody($html);
  8.   $body = $message->get();
  9.   $extraheaders = array("From"=>"Votre nom <votre@gmail.com>",
  10.     "Subject"=>"Sujet du mail",
  11.     "To"=>"Nom destinataire <destinataire@exemple.com>");
  12.   $headers = $message->headers($extraheaders);
  13.  
  14.   $host = "ssl://smtp.gmail.com";
  15.   $port = "465";
  16.   $username = "votre_login_gmail";
  17.   $password = "votre_password_gmail";
  18.  
  19.   $smtp = Mail::factory('smtp',
  20.     array ('host' => $host,
  21.       'port' => $port,
  22.       'auth' => true,
  23.       'username' => $username,
  24.       'password' => $password));
  25.  
  26.   $mail = $smtp->send("destinataire@exemple.com", $headers, $body);
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement