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 can be found in the epel repository. Make sure you have this repo enabled and then run:
# yum install swaks -y
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]
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
Command:
telnet localhost 25Response:
Trying ::1... Connected to localhost. Escape character is '^]'. 220 cloud-server-03.localdomain ESMTP Postfix
HELO localhostResponse:
250 cloud-server-03.localdomain
mail from: [email protected]Response:
250 2.1.0 Ok
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.
(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