Having problem with sending mail from PHP script using google credentials.
authentication failure [SMTP: Invalid response code received from server (code: 534, response: 5.7.14 Please log in via your web browser and 5.7.14 then try again. 5.7.14 Learn more at 5.7.14 https://support.google.com/mail/answer/78754 r14sm3440046pfe.9 - gsmtp)]
// Pear Mail Library
require_once "Mail.php";
$from = '<somename@gmail.com>';
$to = '<anothername@gmail.com>';
$subject = 'Hi!';
$body = "Hi,\n\nHow are you?";
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array(
'host' => 'ssl://smtp.gmail.com',
'port' => '465',
'auth' => true,
'username' => 'somename@gmail.com',
'password' => 'somepassword'
));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo('<p>' . $mail->getMessage() . '</p>');
} else {
echo('<p>Message successfully sent!</p>');
}
With the stack answer i make a try, the answer link is: send-email-using-the-gmail-smtp-server-from-a-php-page
Ref: http://pear.php.net