如何使用SendGrid从Google Compute Engine使用sendmail? [英] How to use sendmail with SendGrid from Google Compute Engine?
问题描述
sendmail
服务。 网站机器在Google Compute Engine内运行,默认情况下,我无法发送电子邮件(这是Google强加的限制)。为了实现发送电子邮件的目的,需要第三方服务,例如SendGrid。
我在SendGrid上创建了一个免费帐户,使用 Google Cloud合作伙伴计划,验证了我的用户等等。该帐户已正确配置。
我配置了我的 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:连接超时与smtp.sendgrid.net。
根据Google ,我的机器无法使用端口 25
, 465
和 587
,所以我将配置更改为使用中的端口
文件。没有任何改变。 2525
sendmail.mc
我遵循本教程以及我继续使用相同的行为。
任何提示?我的机器正在运行Ubuntu 14.04LTS。
好的,我发现问题。
我原来的 /etc/mail/sendmail.mc
文件没有 #dnl define('SMART_HOST','smtp .your.provider')dnl
行,所以我不知道在哪里放置配置(源):
define(`SMART_HOST',`smtp.sendgrid。 net')dnl
FEATURE(`access_db')dnl
define(`RELAY_MAILER_ARGS',`TCP $ h 2525')dnl
define(`ESMTP_MAILER_ARGS',`TCP $ h 2525') dnl
(注意:对于Google Compute Engine机器,您需要使用2525端口而不是默认587)
事情是,你不能把它放在文件的末尾。在不要触摸此处部分之后,配置开始工作:
dnl#由/ etc控制的项目/mail/sendmail.conf - 不要触摸这里
...
DAEMON_OPTIONS(`Family = inet,Name = MSP-v4,Port = submission,M = Ea,Addr = 127.0.0.1') dnl
dnl#SendGrid代码在这里
I have a simple website which runs with Joomla!, and it has a contact form from where the visitor can send a message to me. This message is sent by e-mail using the sendmail
service.
The website machine is running inside Google Compute Engine, and by default I can't send e-mails from it (that's a restriction imposed by Google). To achieve the goal of sending e-mails, a 3rd-party service is needed, such as SendGrid.
I created a free account on SendGrid using the Google Cloud partner program, validated my user and so on. The account is properly provisioned.
I configured my sendmail
service to use SendGrid to deliver the e-mails, according to this tutorial. Everything seems to be ok, but... no message is delivered at all.
My mail log at /var/log/mail.log
shows:
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, my machine can't use the ports 25
, 465
and 587
, so I changed the configuration to use the port 2525
in the sendmail.mc
file. Nothing changed.
I followed this tutorial as well, and I continue with the same behavior.
Any hints? My machine is running Ubuntu 14.04LTS.
Ok, I found the problem.
My original /etc/mail/sendmail.mc
file don't have the #dnl define(‘SMART_HOST’, ‘smtp.your.provider’)dnl
line, so I didn't know exactly where to put the configuration (source):
define(`SMART_HOST', `smtp.sendgrid.net')dnl
FEATURE(`access_db')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 2525')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 2525')dnl
(Note: for Google Compute Engine machines, you need to use the 2525 port instead of the default 587)
The thing is, you can't put it at the end of the file. The configuration started working when I put it just after the "DO NOT TOUCH HERE" section:
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
...
DAEMON_OPTIONS(`Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1')dnl
dnl # SendGrid code here
这篇关于如何使用SendGrid从Google Compute Engine使用sendmail?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!