【发布时间】:2015-01-21 16:36:15
【问题描述】:
我有一个使用 Joomla! 运行的简单网站,它有一个联系表格,访问者可以通过该表格向我发送消息。此消息使用sendmail 服务通过电子邮件发送。
网站机器在 Google Compute Engine 中运行,默认情况下我无法从它发送电子邮件(这是 Google 施加的限制)。要实现发送电子邮件的目的,需要第三方服务,例如 SendGrid。
我使用Google Cloud partner program 在 SendGrid 上创建了一个免费帐户,验证了我的用户等等。该帐户已正确配置。
根据this tutorial,我将我的sendmail 服务配置为使用SendGrid 来传递电子邮件。一切似乎都很好,但是……根本没有传递任何消息。
我在/var/log/mail.log 的邮件日志显示:
Jan 21 16:22:10 web-hosting sm-mta[16350]: t0JHWaec027559: to=<my@email.com>, delay=1+22:49:34, xdelay=00:00:00, mailer=relay, pri=23251559, re
lay=smtp.sendgrid.net., dsn=4.0.0, stat=Deferred: Connection timed out with smtp.sendgrid.net.
According to Google,我的机器无法使用端口25、465和587,所以我在sendmail.mc文件中将配置改为使用端口2525。没有任何改变。
有什么提示吗?我的机器运行的是 Ubuntu 14.04LTS。
【问题讨论】:
-
您是否仔细检查过您的帐户是否正在发送电子邮件?您可以通过 curl 进行测试:
$ curl -d 'to=destination@example.com&amp;toname=Destination&amp;subject=Example Subject&amp;text=testingtextbody&amp;from=info@domain.com&amp;api_user=your_sendgrid_username&amp;api_key=your_sendgrid_password' https://api.sendgrid.com/api/mail.send.json -
@heitortsergent 是的,直接使用 API 可以完美发送邮件。
标签: email sendmail google-compute-engine sendgrid