0

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)]

Sai Kumar
  • 53
  • 1
  • 9
  • 1
    I hope this will be solution http://stackoverflow.com/questions/20337040/gmail-smtp-debug-error-please-log-in-via-your-web-browser – Ayaz Ali Shah Feb 09 '16 at 05:47
  • I tried that solution but its getting same error – Sai Kumar Feb 09 '16 at 05:51
  • May be, [http://stackoverflow.com/questions/23859061/sending-mail-works-from-localhost-but-not-from-remote-server](http://stackoverflow.com/questions/23859061/sending-mail-works-from-localhost-but-not-from-remote-server) ? – Rajdeep Paul Feb 09 '16 at 05:51
  • I am using hostgator sever is there any problem with that? – Sai Kumar Feb 09 '16 at 05:57

0 Answers0