vadossam
7/27/2017 - 1:14 AM

lock SMTP authentication

SMTP authentication

<?php
 ini_set('include_path','.:/opt/alt/php56/usr/share/pear:/home/cPusername/php');
 require_once "Mail.php";
 
 $from = "Sender From <contact@vadym.me>";
 $to = "Recipient <vadim.samofalov@namecheap.com>";
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";
 
 $host = "ssl://mail.privateemail.com";
 $port = "465";
 $username = "contact@vadym.me";
 $password = "27456790rjk";
 
 $headers = array (
   'From' => $from,
   'To' => $to,
   'Subject' => $subject);
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'port' => $port,
     'auth' => true,
     'username' => $username,
     'password' => $password));
 
 $mail = $smtp->send($to, $headers, $body);
 
 if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
   echo("<p>Message successfully sent!</p>");
  }
 ?>