Advertisement
Guest User

Untitled

a guest
May 27th, 2017
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2.  require_once "Mail.php";
  3.  
  4.  $from = "Brief Case <brief@mydomain.com>";
  5.  $to = "Shatil <shatil@example.com>";
  6.  $subject = "Testing SMTP";
  7.  $body = "This message proves that PHP can use SMTP!,\n\nRight?";
  8.  
  9.  $host = "localhost";
  10.  $username = "user@mydomain.com";
  11.  $password = "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.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement