Install the sendmail component in CentOS and test the Mail sending function.

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.