如何在不发送消息的情况下测试我的电子邮件设置?

时间:2022-06-01 18:32:53

As part of my app's config process, I have a sanity checker that validates all user-supplied data. This includes email server settings that the app uses to send email.

作为我的应用程序配置过程的一部分,我有一个完整性验证程序验证所有用户提供的数据。这包括应用用于发送电子邮件的电子邮件服务器设置。

I'd like a simple sanity check on those settings without actually sending any email. It'd be great if this could support all standard flavors of SMTP setups including those with authentication/ssl/etc.

我想在没有实际发送任何电子邮件的情况下对这些设置进行简单的完整性检查。如果这可以支持所有标准版本的SMTP设置,包括那些带有authentication / ssl / etc的设置,那就太棒了。

It doesn't need to be exhaustive but the more coverage, the better.

它不需要详尽无遗,但覆盖范围越大越好。

Currently all I do is verify I can open a connection to the given server on the given port. Something a little deeper would be nice.

目前,我所做的只是验证我可以在给定端口上打开与给定服务器的连接。更深一点的东西会很好。

Note: I'm not trying to validate email addresses--that's not relevant to this question.

注意:我不是要验证电子邮件地址 - 这与此问题无关。

2 个解决方案

#1


You just open a raw connection to the server & port that the user supplies and do a

您只需打开与用户提供的服务器和端口的原始连接并执行操作

HELO Server.Domain.Com
Mail From: validaccount@domain.com

to see if you get a valid HELO response & Sender OK Response (if smtp authentication is enabled).

查看是否获得有效的HELO响应和发件人确定响应(如果启用了smtp身份验证)。

Same as you would do if you telnet direct to the server.

与直接telnet到服务器时的操作相同。

http://www.petri.co.il/test_smtp_service.htm

This might also be useful

这可能也很有用

http://qmail.jms1.net/test-auth.shtml

#2


I'm sure someone brighter and more qualified will pipe up with a better answer. However, at first blush I'd say that you cannot verify the ability to successfully send email without actually sending an email.

我相信有人会更聪明,更有资格,会有更好的答案。但是,乍一看,我会说你无法验证在没有实际发送电子邮件的情况下成功发送电子邮件的能力。

However, if you want to automate the process, you can have a 'MyApp_SanityCheck@gmail.com' (or your local domain) address.

但是,如果要自动执行该过程,可以使用“MyApp_SanityCheck@gmail.com”(或本地域)地址。

Then you can create a watchdog application that monitors that email address, or just a simple app which programmatically interfaces with that email address and checks if an email was received within X minutes. This way you can be 100% certain that the emails are able to be sent out. This link shows how to programmatically check gmail addresses.

然后,您可以创建一个监视该电子邮件地址的监视程序应用程序,或者只是一个以编程方式与该电子邮件地址连接的简单应用程序,并检查是否在X分钟内收到了电子邮件。通过这种方式,您可以100%确定电子邮件是否可以发送出去。此链接显示如何以编程方式检查Gmail地址。

An important note: If you application is sending out external emails, then it would be best if the email address you use is external, because it is possible that your server could be unable to send external emails, but internal emails go through just fine, and in that case your sanity check would send up a false positive.

重要提示:如果您的应用程序正在发送外部电子邮件,那么最好使用您使用的电子邮件地址,因为您的服务器可能无法发送外部电子邮件,但内部电子邮件通过就好了,在这种情况下,你的理智检查会发出误报。

#1


You just open a raw connection to the server & port that the user supplies and do a

您只需打开与用户提供的服务器和端口的原始连接并执行操作

HELO Server.Domain.Com
Mail From: validaccount@domain.com

to see if you get a valid HELO response & Sender OK Response (if smtp authentication is enabled).

查看是否获得有效的HELO响应和发件人确定响应(如果启用了smtp身份验证)。

Same as you would do if you telnet direct to the server.

与直接telnet到服务器时的操作相同。

http://www.petri.co.il/test_smtp_service.htm

This might also be useful

这可能也很有用

http://qmail.jms1.net/test-auth.shtml

#2


I'm sure someone brighter and more qualified will pipe up with a better answer. However, at first blush I'd say that you cannot verify the ability to successfully send email without actually sending an email.

我相信有人会更聪明,更有资格,会有更好的答案。但是,乍一看,我会说你无法验证在没有实际发送电子邮件的情况下成功发送电子邮件的能力。

However, if you want to automate the process, you can have a 'MyApp_SanityCheck@gmail.com' (or your local domain) address.

但是,如果要自动执行该过程,可以使用“MyApp_SanityCheck@gmail.com”(或本地域)地址。

Then you can create a watchdog application that monitors that email address, or just a simple app which programmatically interfaces with that email address and checks if an email was received within X minutes. This way you can be 100% certain that the emails are able to be sent out. This link shows how to programmatically check gmail addresses.

然后,您可以创建一个监视该电子邮件地址的监视程序应用程序,或者只是一个以编程方式与该电子邮件地址连接的简单应用程序,并检查是否在X分钟内收到了电子邮件。通过这种方式,您可以100%确定电子邮件是否可以发送出去。此链接显示如何以编程方式检查Gmail地址。

An important note: If you application is sending out external emails, then it would be best if the email address you use is external, because it is possible that your server could be unable to send external emails, but internal emails go through just fine, and in that case your sanity check would send up a false positive.

重要提示:如果您的应用程序正在发送外部电子邮件,那么最好使用您使用的电子邮件地址,因为您的服务器可能无法发送外部电子邮件,但内部电子邮件通过就好了,在这种情况下,你的理智检查会发出误报。