Michael Haren
Michael Haren

Reputation: 108276

How do I test my email settings without sending a message?

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.

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.

Upvotes: 3

Views: 2047

Answers (2)

Eoin Campbell
Eoin Campbell

Reputation: 44278

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

HELO Server.Domain.Com
Mail From: [email protected]

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

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

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

This might also be useful

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

Upvotes: 5

DevinB
DevinB

Reputation: 8316

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 '[email protected]' (or your local domain) address.

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.

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.

Upvotes: 1

Related Questions