简体   繁体   English

使用PHPMailer和gmail在Heroku上发送电子邮件

[英]Using PHPMailer and gmail to send emails on Heroku

I want to log in to my gmail account from an Heroku app using PHPMailer but gmail restricts access since the remote server is an unknown device. 我想使用PHPMailer从Heroku应用程序登录到我的Gmail帐户,但由于远程服务器是未知设备,因此Gmail限制了访问权限。 Is there a workaround to this? 有没有解决方法? I have tried using the captcha but its not helping. 我尝试使用验证码,但没有帮助。

Please note that i have no issue connecting to gmail on localhost. 请注意,在本地主机上连接gmail我没有问题。 Problem comes when i deploy and my guess is that it is because gmail restricts it. 问题出在我部署时,我的猜测是这是因为gmail限制了它。

I actually stumbled across an answer. 我实际上偶然发现了一个答案。 The solution is to actually follow this link and follow the instructions. 解决方案是实际遵循此链接并按照说明进行操作。 First you have to allow less secure apps setting in your gmail account. 首先,您必须允许 Gmail帐户中的安全性较低的应用程序设置。 Before following the link you have to sign out from all logged in accounts so that you do not allow for the wrong email. 在点击链接之前,您必须从所有已登录帐户中注销,以免收到错误的电子邮件。 My mistake was that i followed the link before logging out thus allowed for a different email. 我的错误是我在注销之前先跟踪了链接,从而允许使用其他电子邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM