2017-05-15 69 views
0

此Meteor服務器代碼嘗試從服務器啓動發送電子郵件。
在閱讀AWS docs後,我遵循的步驟如下:
1)驗證也在AWS webMail上的電子郵件地址。
2)適用於增加發送限制。
3)創建並接收SMTP憑據。使用AWS SMTP設置流星電子郵件

流星1.4.4.2
[email protected]

//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: '[email protected]', 
     subject: 'sending-to-myselft', 
     text: 'Just checking if it is working' 
     }); 
}); 

Error: 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; 

的錯誤,現在是:

Error: Greeting never received

更改端口爲 「587」 給出了不同的錯誤:

Error: Mail command failed: 501 Invalid MAIL FROM address provided

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

端口25上的測試沒有任何證明。 EC2在端口25上做了一些創造性的過濾。端口465僅僅是TLS,因此客戶首先談論......因此這兩者都很好。測試端口587(順便提一下,這是正確的端口)也顯示了我所期望的。堅持587.你能捕獲一些SMTP事務調試返回'501'錯誤?這應該告訴你,你需要知道什麼...雖然,Email.send({...'需要從**地址**,不是嗎? –

+0

通過將端口更改爲587並添加「from 「正如所建議的那樣,現在它沒有任何錯誤地工作 –

回答

1

您正在解決兩個同時發生的問題,並且當您修復其中一個問題時,並不明顯您正在取得進展,因爲您遇到了另一個問題。

對於出站電子郵件,SES會偵聽兩組端口。標準端口587,傳統的(但錯誤的)端口25,和標準的端口465上的非特權端口2587.

TLS包裝,和無特權的端口2465.

的差異上

STARTTLS這兩組之間是如何協商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地址正在被指定。