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).
我正在尝试创建一个处理paypal支付的测试站点。在成功支付(我的IPN)后,我尝试用PHP SwiftMailer向用户发送电子邮件。
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.
我试过使用googlemail和另一封在共享服务器下托管的电子邮件,但它们都有出错的问题。
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.
我做了一些研究,并尝试了几种方法来设置我的交通。但似乎仍然没有什么有效的办法。直到我尝试将IPN代码放到另一个托管公司的另一个服务器上,它才令人惊讶地工作。同样的代码来自另一个。
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?
我是否需要确保在我的服务器上启用SwiftMailer工作?
3 个解决方案
#1
18
This might be old but somebody might get help through this. I too faced the same problem and received a mail on my gmail account stating that someone is trying to hack your account through an email client or a different site. THen I searched and found that doing below would resolve this issue.
这可能是旧的,但有人可能通过这个得到帮助。我也遇到了同样的问题,在我的gmail账户上收到了一封邮件,说有人试图通过电子邮件客户端或其他网站侵入你的账户。然后我搜索并发现下面的操作可以解决这个问题。
Go to https://accounts.google.com/UnlockCaptcha and unlock your account for access through other media/sites.
去https://accounts.google.com/UnlockCaptcha和释放你的账户访问通过其他媒体/网站。
UPDATE : 2015
更新:2015
Also, you can try this, Go to https://myaccount.google.com/security#connectedapps At the bottom, towards right there is an option "Allow less secure apps". If it is "OFF", turn it on by sliding the button.
同样,你也可以试试这个,到下面的https://myaccount.google.com/security#connectedapps,右边有一个选项“允许不安全的应用”。如果是“OFF”,请按下按钮打开。
#2
5
As already stated this might be old but you can try and allow gmail to send mails through less secure apps.
如前所述,这可能是旧的,但是您可以尝试并允许gmail通过不太安全的应用程序发送邮件。
https://www.google.com/settings/security/lesssecureapps
https://www.google.com/settings/security/lesssecureapps
This made it work for me and I had the same issue.
这让它对我起作用,我也有同样的问题。
#3
3
I know this is old but hopefully this points someone in the right direction. I had this same problem when using a Mandrill and Swiftmailer combination.
我知道这已经是老生常谈了,但我希望这能帮助我们找到正确的方向。我在使用Mandrill和Swiftmailer组合时遇到过同样的问题。
My issue was that the server was stopping SMTP messages from port 587, and this was in relation to the FKA SMTP Tweak settings which were on my server.
我的问题是,服务器正在从端口587停止SMTP消息,这与我服务器上的FKA SMTP微调设置有关。
So if you have Cpanel and can access WHM, try looking at your mail settings under tweaks to see if outgoing SMTP mail is restricted. Other option is that maybe your server considers a port as suspicious. Try changing the port, I found that my hosting company had a list of suitable ports.
因此,如果您有Cpanel并且可以访问WHM,那么可以尝试查看您的邮件设置,以查看是否将发送的SMTP邮件受到限制。另一种选择是,您的服务器可能认为端口是可疑的。尝试更改端口,我发现我的托管公司有一个合适的端口列表。
#1
18
This might be old but somebody might get help through this. I too faced the same problem and received a mail on my gmail account stating that someone is trying to hack your account through an email client or a different site. THen I searched and found that doing below would resolve this issue.
这可能是旧的,但有人可能通过这个得到帮助。我也遇到了同样的问题,在我的gmail账户上收到了一封邮件,说有人试图通过电子邮件客户端或其他网站侵入你的账户。然后我搜索并发现下面的操作可以解决这个问题。
Go to https://accounts.google.com/UnlockCaptcha and unlock your account for access through other media/sites.
去https://accounts.google.com/UnlockCaptcha和释放你的账户访问通过其他媒体/网站。
UPDATE : 2015
更新:2015
Also, you can try this, Go to https://myaccount.google.com/security#connectedapps At the bottom, towards right there is an option "Allow less secure apps". If it is "OFF", turn it on by sliding the button.
同样,你也可以试试这个,到下面的https://myaccount.google.com/security#connectedapps,右边有一个选项“允许不安全的应用”。如果是“OFF”,请按下按钮打开。
#2
5
As already stated this might be old but you can try and allow gmail to send mails through less secure apps.
如前所述,这可能是旧的,但是您可以尝试并允许gmail通过不太安全的应用程序发送邮件。
https://www.google.com/settings/security/lesssecureapps
https://www.google.com/settings/security/lesssecureapps
This made it work for me and I had the same issue.
这让它对我起作用,我也有同样的问题。
#3
3
I know this is old but hopefully this points someone in the right direction. I had this same problem when using a Mandrill and Swiftmailer combination.
我知道这已经是老生常谈了,但我希望这能帮助我们找到正确的方向。我在使用Mandrill和Swiftmailer组合时遇到过同样的问题。
My issue was that the server was stopping SMTP messages from port 587, and this was in relation to the FKA SMTP Tweak settings which were on my server.
我的问题是,服务器正在从端口587停止SMTP消息,这与我服务器上的FKA SMTP微调设置有关。
So if you have Cpanel and can access WHM, try looking at your mail settings under tweaks to see if outgoing SMTP mail is restricted. Other option is that maybe your server considers a port as suspicious. Try changing the port, I found that my hosting company had a list of suitable ports.
因此,如果您有Cpanel并且可以访问WHM,那么可以尝试查看您的邮件设置,以查看是否将发送的SMTP邮件受到限制。另一种选择是,您的服务器可能认为端口是可疑的。尝试更改端口,我发现我的托管公司有一个合适的端口列表。