Advertisement
Guest User

Untitled

a guest
Jun 28th, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. function sendEmail($from, $to, $sub, $body){
  2.     require_once "Mail.php"; //ez a sima pear-es mailer https://pear.php.net/package/Mail
  3.    
  4.     $host = "smtpszerver";
  5.     $port = "587";
  6.     $username = "username";
  7.     $password = "pass";
  8.     $headers = array (
  9.             'From' => $from,
  10.             'To' => $to,
  11.             'Subject' => $sub,
  12.             'Content-Type' => "text/plain; charset=UTF-8\r\n"
  13.     );
  14.  
  15.     $smtp = Mail::factory('smtp',
  16.             array (
  17.                 'host' => $host,
  18.                 'port' => $port,
  19.                 'auth' => true,
  20.                 'username' => $username,
  21.                 'password' => $password,
  22.                 'SMTPSecure' => "tls"
  23.             )
  24.     );
  25.     $mail = $smtp->send($to, $headers, $body);
  26.    
  27.     if(PEAR::isError($mail)) {
  28.         return $mail->getMessage();
  29.     }else{
  30.         return "Message successfully sent!";
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement