I am trying to send SMTP email using below php code.
<?php
require_once "Mail.php";
$from = "info@XXXXX.com";
$to = "info@XXXXXX.com";
$subject = "Hi";
$body = "Hi,\n\nHow are you?\nDoing anything this Friday evening?\n";
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "xxxxx";
$password = "xxxxx";
$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>" );
}
?>
While i am executing the code from unix webserver webpage. I am getting following error.
authentication failure [SMTP: Invalid response code received from server (code: 535, response: Incorrect authentication data)]
But the above code working fine in my localhost.
Please help me to finish the project.
Thanks.