此Meteor服务器代码尝试从服务器启动发送电子邮件
阅读AWS docs后我遵循的步骤是:
1)验证AWS webMail上的电子邮件地址
2)适用于增加发送限制
3)创建并接收SMTP凭据。
流星1.4.4.2
email@1.2.1
//server/main.js
smtp = {
'username': 'from smtp credentials',
'password': 'from smtp credentials',
'host': 'email-smtp.us-east-1.amazonaws.com',
'port': '465',
'auth': true
};
process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '@' + encodeURIComponent(smtp.outgoingServer) + ':' + smtp.outgoingPort;
Meteor.startup(() => {
Email.send({
to: 'my-aws-verified-email@comp.com',
subject: 'sending-to-myselft',
text: 'Just checking if it is working'
});
});
错误:getaddrinfo ENOTFOUND undefined undefined:587
知道如何让它发挥作用吗? THX
修改
将process.env.MAIL_URL
值更改为:
process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) +
':' + encodeURIComponent(smtp.password) +
'@' + encodeURIComponent(smtp.host) +
':' + smtp.auth + ':' + smtp.port;
现在的错误是:
错误:问候从未收到
将端口更改为“587”会产生不同的错误:
错误:邮件命令失败:501提供的邮件地址无效
telnet email-smtp.us-east-1.amazonaws.com 465
Trying 107.21.244.69...
Connected to ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com.
Escape character is '^]'.
Connection closed by foreign host.
telnet email-smtp.us-east-1.amazonaws.com 2465
Trying 54.221.247.194...
Connected to ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com.
Escape character is '^]'.
Connection closed by foreign host.
telnet email-smtp.us-east-1.amazonaws.com 25
Trying 54.243.106.227...
telnet: connect to address 54.243.106.227: Connection refused
Trying 107.21.244.69...
telnet: connect to address 107.21.244.69: Connection refused
Trying 23.21.91.54...
telnet: connect to address 23.21.91.54: Connection refused
Trying 50.19.94.229...
telnet: connect to address 50.19.94.229: Connection refused
Trying 54.235.77.145...
telnet: connect to address 54.235.77.145: Connection refused
Trying 54.243.97.84...
telnet: connect to address 54.243.97.84: Connection refused
Trying 23.23.104.248...
telnet: connect to address 23.23.104.248: Connection refused
Trying 54.221.247.194...
telnet: connect to address 54.221.247.194: Connection refused
telnet: Unable to connect to remote host
telnet email-smtp.us-east-1.amazonaws.com 587
Trying 54.221.247.194...
Connected to ses-smtp-prod-t5t357831.us-east-1.elb.amazonaws.com.
Escape character is '^]'.
220 email-smtp.amazonaws.com ESMTP SimpleEmailService-1110753669 CalqM0Qfzgny2ooZ0wo5
421 Timeout waiting for data from client.
Connection closed by foreign host.
telnet email-smtp.us-east-1.amazonaws.com 2587
Trying 23.23.104.248...
Connected to ses-smtp-prod-337800831.us-east-1.elb.amazonaws.com.
Escape character is '^]'.
220 email-smtp.amazonaws.com ESMTP SimpleEmailService-20753669yy 4qrIfUj4ApTwkj4ZJUNa
421 Timeout waiting for data from client.
Connection closed by foreign host.
答案 0 :(得分:1)
你正在解决两个同时发生的问题,当你修复其中一个问题时,你没有取得进展并不明显,因为那时你遇到了另一个问题。
对于出站电子邮件,SES会侦听两组端口。
标准端口587上的STARTTLS,传统(但错误)端口25,以及无特权端口2587.
标准端口465上的TLS Wrapper和非特权端口2465.
两组之间的区别在于如何协商SSL(TLS)。使用STARTTLS,服务器首先进行通信,客户端要求连接切换到加密模式...使用TLS Wrapper时,连接从TLS开始,但客户端首先进行会话,启动TLS协商。
显然,根据这些描述,当客户端预期使用STARTTLS时使用TLS Wrapper端口将导致超时,因为双方都在等待另一方通话。
端口25不是赢家,因为EC2默认启用了激进的速率限制,以防止明显的垃圾邮件问题。您可以通过提交支持请求来要求禁用此功能,但最简单的解决方案是使用端口587。
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-connect.html
然后,您的客户端没有设置发件人地址,因为没有指定from
地址。