I have installed pear mail library
Using pear mail library sending mail from localhost(XAMPP) but same code uploaded into server it getting Authentication failure
how to overcome this issue?
Mycode is
<?php
require_once "Mail-1.3.0/Mail.php";
$from = '<mymail@gmail.com>';
$to = '<mail2@gmail.com>';
$subject = 'Hi!';
$body = "Hi,\n\nHow are you?";
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array(
'host' => 'smtp.gmail.com',
'port' => '465',
'auth' => true,
'username' => 'mymail@gmail.com',
'password' => 'password'
));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo('<p>' . $mail->getMessage() . '</p>');
} else {
echo('<p>Message successfully sent!</p>');
}
?>
Error:
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 k8sm1257567oig.13 - gsmtp)]