Simulate sending an email

Detailed manual e-mail procedure

For diagnostic purposes, it can be very useful to simulate the sending of an email to a mail server, in order to understand why an email fails to reach a recipient’s mail server. In this article, we’ll describe a detailed procedure for simulating the sending of an email, with the aim of debugging such a situation.

This operation must be carried out in 2 stages: DNS request, sending the mail itself. These two steps are imperative. It would be a big mistake to avoid the first step, DNS analysis, just because you already know the name of the destination server. What’s more, these steps must be carried out from the sending mail server, to ensure that the DNS servers used for the queries are indeed the same, and that the sending IP address corresponds to the one seen by the destination server.

First step: find out the name of your mail server
You need to know the name(s) of the mail server that handles mail for the domain name you’re interested in. This is entered in the MX field(s) of the DNS zone that manages the domain name.

If you are using Windows :
Using the nslookup command :
> set q=MX
The system returns a list of MX fields
> exit
The main server is the one with the lowest priority.

If your mail server’s operating system is Linux :
You can use the dig or host commands:
# host -t MX (or) # host -t MX

root@a10:~# host -t MX mail is handled by 10 mail is handled by 20

AirFrance’s main mail server is:

Second step: simulate sending an email
Once you know the name or IP address of the mail server, you can simulate sending an e-mail using the telnet command on port 25, which is the SMTP protocol port.

Example of a correctly transmitted e-mail:

# telnet 25
250 ok
mail from: (valid email address)
250 2.1.0 Ok
rcpt to: (email address valid in the tested domain)
250 2.1.5 Ok
354 Enter mail, end with “.” on a line by itself
test mail sending (mail text)
. (to finish the mail)
250 2.0.0 Ok: queued as 3FE2C8181C9
221 2.0.0 Bye

Example of an error message (anti-relay) :

# telnet 25
mail from:
250 sender <> ok
rcpt to:
550 #5.1.0 Address rejected.

For details of the SMTP protocol, see the following article: here

The codes returned by mail servers are of 3 types:
2xx = acceptance
4xx = temporary refusal (e.g. Greylisting )
5xx = permanent refusal (usually followed by an error message, which may be more or less explicit)

In this example, the mail server has responded with a code 250, so the mail is accepted and its identifier in the server is 3FEC8181C9. You can press “quit” instead of data, so that no e-mail is sent and you have checked the validity of the address.

ALTOSPAM has developed an interesting tool, freely accessible here, to simulate the whole procedure. In this case, the test is obviously not performed from your mail server, but it does give a very good indication of the remote domain’s configuration.

The article here shows how to use our online tool to validate a recipient’s domain or email address.

Test Altospam’s solutions!

Thousands of companies, CTOs, CIOs, CISOs and IT managers already trust us to protect their e-mail against phishing, spear phishing, ransomware, …