What is Mailx?
Postfix is an Mail Server (MTA) — a Message Transfer Agent.
Mailx is an Mail Client (MUA) — a Mail User Agent. Mailx used for send and recieve emails from Mail Server (Postfix)
How does it work?
mail -> sendmail -> local MTA -> recipient MTA [Inbox]
# Check Postfix and Mailx is Installed and Running
yum install -y postfix
yum install -y mailx
systemctl enable postfix
systemctl restart postfix
# Check the non-default configuration
postconf -n
# Set relayhost to postfix configuration
postconf -e 'relayhost = 192.168.1.1'
# Check the syntax
postfix check
# Open the firewall if you want to receive emails from outside
firewall-cmd --permanent --add-service=smtp
firewall-cmd --reload
# Test
echo "This is a test." | mail -s "Test" me@example.com
# Troubleshooting
netstat -ltnp | grep 25
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 13303/master
tcp6 0 0 ::1:25 :::* LISTEN 13303/master
# Usage Options
# -v = Verbosity
# -s = Specifies the subject.
# -r = Email sent from.
# -c = CC
# -b = BCC
# -S = Specifies the smtp server.
# -a = Attachment
# Some Examples
echo "This is test mail" | mail -r "FROM" -s "SUBJECT" mahmut.deniz@domain.com.tr
mailx -s "SUBJECT" mahmut.deniz@domain.com.tr < message.txt
more message.txt | mailx -s deneme mahmut.deniz@domain.com.tr,ege.deniz@yok.gov.tr
mailx -a file.txt -s "Subject" mahmut.deniz@domain.com.tr < /dev/null
Etiketler :
Linux