简体   繁体   English

如何使用 telnet 使用 Mailgun 通过 SMTP 发送测试电子邮件?

[英]How to send a test email over SMTP with Mailgun using telnet?

I have configured Mailgun for my domain: blog.kop.com (fake domain), I have reset my SMTP password for this domain on mailgun dashboard.我已经为我的域配置了 Mailgun: blog.kop.com (假域),我已经在 mailgun 仪表板上重置了这个域的 SMTP 密码。

I usually use the Mailgun API, this is why I want to test the SMTP sending from command line to check that I have the correct credentials, as an example, I'll use the following password:我通常使用 Mailgun API,这就是为什么我想测试从命令行发送的 SMTP 以检查我是否拥有正确的凭据,例如,我将使用以下密码:

  • Username: postmaster@blog.kop.com (guessed by me)用户名: postmaster@blog.kop.com (我猜的)
  • Password: d3bec33d3bc3e333333b3e333a3e33-3a3aa3d3-333ddf3 (given by mailgun)密码: d3bec33d3bc3e333333b3e333a3e33-3a3aa3d3-333ddf3 (由mailgun提供)

This is what I do:这就是我所做的:

  1. Convert the username to base64:username转换为 base64:
$ echo postmaster@blog.kop.com | base64
cG9zdG1hc3RlckBibG9nLmtvcC5jb20K
  1. Convert the password to base64:password转换为 base64:
$ echo d3bec33d3bc3e333333b3e333a3e33-3a3aa3d3-333ddf3 | base64
ZDNiZWMzM2QzYmMzZTMzMzMzM2IzZTMzM2EzZTMzLTNhM2FhM2QzLTMzM2RkZjMK
  1. Test send email over SMTP on port 587 (STARTTLS) with telnet client:使用telnet客户端在端口587 (STARTTLS) 上测试通过 SMTP 发送电子邮件:
$ telnet smtp.mailgun.org 587
Trying 3.93.221.84...
Connected to smtp.mailgun.org.
Escape character is '^]'.
220 Mailgun Influx ready
ehlo blog.kop.com
250-smtp-out-n01.prod.us-east-1.postgun.com
250-AUTH PLAIN LOGIN
250-SIZE 52428800
250-8BITMIME
250-SMTPUTF8
250-PIPELINING
250 STARTTLS
AUTH LOGIN
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBibG9nLmtvcC5jb20K
334 UGFzc3dvcmQ6
ZDNiZWMzM2QzYmMzZTMzMzMzM2IzZTMzM2EzZTMzLTNhM2FhM2QzLTMzM2RkZjMK
535 Authentication failed
Connection closed by foreign host.

It seems that my credentials are incorrect, this is mailgun documentation for sending mail over SMTP: https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-smtp似乎我的凭据不正确,这是通过 SMTP 发送邮件的 mailgun 文档: https ://documentation.mailgun.com/en/latest/user_manual.html#sending-via-smtp

I also tried using there code snippet and their swaks program: https://documentation.mailgun.com/en/latest/quickstart-sending.html#send-via-smtp我也尝试使用那里的代码片段和他们的swaks程序: https : swaks

I also have the wrong credentials.我也有错误的凭据。 I copy pasted the credentials and aknowledged that they are correct.我复制粘贴了凭据并确认它们是正确的。

I already got this issue using the API, the mailgun documentation was providing the wrong api address for europe region.我已经使用 API 遇到了这个问题,mailgun 文档为欧洲地区提供了错误的 api 地址。 I now believe smtp.mailgun.org is not the right server for Europe region but I can't find anything related to it.我现在相信smtp.mailgun.org不是欧洲地区的合适服务器,但我找不到任何与之相关的内容。

  • What's wrong with those steps?这些步骤有什么问题?
  • Why I am failing to send email?为什么我发送电子邮件失败?
  • How can I send email over SMTP with mailgun, starttls and telnet?如何使用 mailgun、starttls 和 telnet 通过 SMTP 发送电子邮件?

When you echo a string you include a newline, but the newline should not be included in the credentials you pass in to SMTP AUTH .当您echo一个字符串时,您会包含一个换行符,但该换行符不应包含在您传递给SMTP AUTH的凭据中。 Try尝试

printf '%s' 'postmaster@blog.kop.com' | base64

and similarly for the password.密码也类似。

Using bare Telnet sounds like a pretty brittle approach;使用裸 Telnet 听起来是一种非常脆弱的方法; you really want to use a proper SMTP client to talk to the SMTP server.您确实想使用合适的 SMTP 客户端与 SMTP 服务器通信。

对于欧洲,SMTP 地址是smtp.eu.mailgun.org

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

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