I am trying to create a test site that handles paypal payment. I am trying to send users an email using PHP SwiftMailer after a successful payment (which is my IPN).
Here is my code for the transport:
$transport = Swift_SmtpTransport::newInstance('smtp.googlemail.com', 465, 'ssl')
->setUsername('xxx@xxx.co.uk')
->setPassword('xxxx');
$mailer = Swift_Mailer::newInstance($transport);
I have tried to use googlemail and another email which is hosted under a shared server and both have problems giving out an error.
Unfortunately, I am getting this usual error:
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Failed to authenticate on SMTP server with username "xxx@xxx.co.uk" using 2 possible authenticators' in /home/xxx/public_html/paypal/lib/classes/Swift/Transport/Esmtp/AuthHandler.php:184
Stack trace:
#0 /home/xxx/public_html/paypal/lib/classes/Swift/Transport/EsmtpTransport.php(312): Swift_Transport_Esmtp_AuthHandler->afterEhlo(Object(Swift_SmtpTransport))
#1 /home/xxx/public_html/paypal/lib/classes/Swift/Transport/AbstractSmtpTransport.php(120): Swift_Transport_EsmtpTransport->_doHeloCommand()
#2 /home/xxx/public_html/paypal/lib/classes/Swift/Mailer.php(80): Swift_Transport_AbstractSmtpTransport->start()
#3 /home/xxx/public_html/paypal/ipn.php(113): Swift_Mailer->send(Object(Swift_Message))
#4 /home/mctikudo/public_html/paypal/ipn.php(46): sendMail(Resource id #3, Array)
#5 {main} thrown in /home/xxx/public_html/paypal/lib/classes/Swift/Transport/Esmtp/AuthHandler.php on line 184
I have done some research and tried several approach in the setting of my transport. But still nothing seems to work. Until I just tried to place my IPN code to another server under another hosting company and surprisingly, it works. Same code from the other one.
This is why I guess there is something in the other server must be set or something.
Are there things that I need to make sure that is enabled on my server to have the SwiftMailer work?