email:test_smtp
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
email:test_smtp [2016/07/04 23:27] – peter | email:test_smtp [2019/11/27 22:15] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Email - Test SMTP ====== | ||
- | |||
- | The commands used here are covered in section 4.1 of RFC 2821 [http:// | ||
- | |||
- | ===== Obtain the DNS MX record for a domain ===== | ||
- | |||
- | Issue the following command: | ||
- | |||
- | **Linux:** | ||
- | |||
- | <code bash> | ||
- | nslookup -type=mx sharewiz.net | ||
- | |||
- | Non-authoritative answer: | ||
- | sharewiz.net | ||
- | |||
- | Authoritative answers can be found from: | ||
- | mail.sharewiz.net internet address = 5.42.134.35 | ||
- | </ | ||
- | |||
- | |||
- | **Windows: | ||
- | |||
- | <code bash> | ||
- | nslookup -type=mx sharewiz.net | ||
- | Non-authoritative answer: | ||
- | sharewiz.net | ||
- | </ | ||
- | |||
- | |||
- | ===== Get the DNS PTR for the IP ===== | ||
- | |||
- | This requires to know what IP address. | ||
- | |||
- | With the IP address run the following command, where A.B.C.D is the IP address. | ||
- | |||
- | **Linux:** | ||
- | |||
- | <code bash> | ||
- | nslookup -type=ptr A.B.C.D | ||
- | Non-authoritative answer: | ||
- | </ | ||
- | |||
- | **Windows: | ||
- | |||
- | <code bash> | ||
- | nslookup -type=ptr A.B.C.D | ||
- | Non-authoritative answer: | ||
- | </ | ||
- | |||
- | |||
- | So now that we have the MX record for example.com and the PTR for the IP we are going to use, it is time to login to the SMTP server. | ||
- | |||
- | |||
- | ===== Connect to server ===== | ||
- | |||
- | For non-secure SMTP, you can use | ||
- | |||
- | <code bash> | ||
- | telnet example.com 25 | ||
- | </ | ||
- | |||
- | For secure SMTP, you can use one of following: | ||
- | |||
- | <code bash> | ||
- | openssl s_client -starttls smtp -connect example.com: | ||
- | openssl s_client -starttls smtp -connect example.com: | ||
- | openssl s_client -starttls smtp -connect example.com: | ||
- | </ | ||
- | |||
- | As soon as you connect to the server, run: | ||
- | |||
- | <code bash> | ||
- | ehlo example.com | ||
- | </ | ||
- | |||
- | You will get output like below as reply: | ||
- | |||
- | < | ||
- | 250-test.rtcamp.com | ||
- | 250-PIPELINING | ||
- | 250-SIZE 10240000 | ||
- | 250-VRFY | ||
- | 250-ETRN | ||
- | 250-STARTTLS | ||
- | 250-AUTH PLAIN LOGIN | ||
- | 250-ENHANCEDSTATUSCODES | ||
- | 250-8BITMIME | ||
- | 250 DSN | ||
- | </ | ||
- | |||
- | If you do not see line like 250-AUTH ... line, then your server may not support authentication. | ||
- | |||
- | |||
- | ===== Authentication ===== | ||
- | |||
- | For admin@example.com and password, generate base64 encoded string like below: | ||
- | |||
- | <code bash> | ||
- | echo -ne ' | ||
- | </ | ||
- | |||
- | Please note use of **\0** before username and password. | ||
- | |||
- | It will output a string like below: | ||
- | |||
- | < | ||
- | AGFkbWluQGV4YW1wbGUuY29tAHBhc3N3b3Jk | ||
- | </ | ||
- | |||
- | Use above string with AUTH command: | ||
- | |||
- | <code bash> | ||
- | AUTH PLAIN AGFkbWluQGV4YW1wbGUuY29tAHBhc3N3b3Jk | ||
- | </ | ||
- | |||
- | |||
- | ===== SMTP Commands to send test email ===== | ||
- | |||
- | Type/paste following commands 1-by-1. | ||
- | |||
- | <code bash> | ||
- | ehlo example.com | ||
- | mail from: admin@example.com | ||
- | rcpt to: admin@other.com | ||
- | data | ||
- | quit | ||
- | </ | ||
- | |||
- | For more SMTP Tests, check http:// | ||
- | |||
- | ===== Open-Relay Test ===== | ||
- | |||
- | Worst thing that could happen to your SMTP server is – it becomes open-relay (accidentally). | ||
- | |||
- | There are many tools available online which can check if your smtp server is acting as open relay. | ||
- | |||
- | ===== swaks utility ===== | ||
- | |||
- | This is a small package which can make it easy to test your smtp server. | ||
- | |||
- | <code bash> | ||
- | apt-get install swaks | ||
- | </ | ||
- | |||
- | Example usage: | ||
- | |||
- | <code bash> | ||
- | swaks --server example.com --to admin@example.com | ||
- | </ | ||
- | |||
- | Please note that SpamAssassin marks, swaks generated email as spam. | ||
email/test_smtp.1467674858.txt.gz · Last modified: 2020/07/15 09:30 (external edit)