Install sendmail
Run:
[Root @ vps478753 ~] # Yum-y install sendmail
The program will automatically search for the sendmail installer for automatic installation.
After installing sendmail, run the following command to start sendmail.
[Root @ vps478753 ~] # Service sendmail start
Starting sendmail: [OK]
Starting sm-client: [OK]
After starting, we can run the mail command to test whether emails can be sent.
1. Send an email through the file content
First, create a body.txt
[Root @ vps478753 ~] # Touch body.txt
Write content
[Root @ vps478753 ~] # Echo 'this is test mail'> body.txt
Send email
[Root @ vps478753 ~] # Mail-s 'test mail' admin@vpsrr.com <body.txt will receive the mail soon
Click to open the content of body.txt.
This is test mail
2. Use the MPs queue to directly send the email content
If you do not want to send the email content through the file, you can also send it like this.
[Root @ vps478753 ~] # Echo "This is test mail" | mail-s 'test mail' admin@vpsrr.com
The above results are the same as the content of the email sent by the file.
If mail: command not found is prompted
[Root @ vps478753 ~] # Mail-s 'test mail' admin@vpsrr.com <body.txt
-Bash: mail: command not found
The mail command is not installed. In this case, the mail command must be installed.
[Root @ vps478753 ~] # Yum install mailx-y
Then try again to send the following email!
Note: If a firewall is installed, add the following rules:
Iptables settings
# Iptables-a input-p tcp-dport 25-j ACCEPT
# Iptables-a input-p udp-dport 25-j ACCEPT