There are 2 main methods for sending/testing outgoing mail:



My favourite is using swaks as its easy to use and quick. You will probably need to install though:

SWAKS

Swaks can be found in the epel repository. Make sure you have this repo enabled and then run:

# yum install swaks -y

Testing your local mail server

The following command tests your local mail configuration (postfix). This includes the relay that may be configured with it.

swaks --to [email protected] --server 127.0.0.1 -from [email protected]

Testing the relay host

The following command will send mail directly to the relay (for example sendgrid or mailgun).
Change “username” to the username you normally authenticate with to the relay host and you will be prompted for a password once you run the following command:

swaks --to [email protected] --server smtp.sendgrid.net:587 --auth-user username -tls


Telnet

Command:

telnet localhost 25
Response:
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 cloud-server-03.localdomain ESMTP Postfix

Command
HELO localhost
Response:
250 cloud-server-03.localdomain

Command
mail from: [email protected]
Response:
250 2.1.0 Ok

Command
rcpt to: [email protected]
Response:
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Type some data and then end the email with a `.` on a line by itself.
Press enter to escape and the type quit

Mail Troubleshooting

ubuntu

(Host or domain name not found. Name service error for name=random.com type=MX: Host not found, try again)
Check that resolv.conf and /var/spool/postfix/etc/resolv.conf match:
cat /etc/resolv.conf
cat /var/spool/postfix/etc/resolv.conf

The Debian install is chrooted by default. A simple restart of the service should populate the appropriate files .