Solution to slow email sending using the mail function in Centos

Source: Internet
Author: User


Because you often need to back up website data, you have learned how to send emails through shell in linux. Here we use CentOS

For example, use the mail command to send external emails. The syntax of the mail command is as follows:

The code is as follows: Copy code

Usage: mail [-iInv] [-s subject] [-c cc-addr] [-B bcc-addr] to-addr ...[--

Sendmail-options...] mail [-iInNv]-f [name] mail [-iInNv] [-u user]


Use the mail command to send an email,

1. Directly use shell as the editor

The code is as follows: Copy code

Mail-s "Hello from mzone. cc by shell" admin@mzone.cchello, this is the content

Mail. welcome to www.111cn.net

The first line is the input command,-s represents the subject of the mail, followed by the admin@mzone.cc is the recipient of the Mail, after entering this line

After the command is run, press enter to write the mail body. We can enter any text, such as the preceding two lines. When the body of the email is entered

Press CTRL + D to complete the input. At this time, you will be prompted to enter the Cc address, that is, the Mail Cc address. If you do not press enter, the Mail is completed.

.
 
After the restart, I can send an email, but the speed is slow. I deleted the function, and later found that it was my original VPS.

Because, can solve, the following solution is provided:

First, connect to the VPS through SSH, and enter the following command to view the parsing File: cat/etc/hosts

Appears:

The code is as follows: Copy code

# Do not remove the following line, or various programs
# That require network functionality will fail.
127.0.0.1 localhost. localdomain localhost
198.46.146.48 aiteyu


Because sendmail is listening for 127.0.0.1, but the host name aiteyu cannot be confirmed (because

The HOSTNAME recorded in the/etc/sysconfig/network file is aiteyu), so sending the mail is very slow. Then

The host name aiteyu is also added after 127.0.0.1 and changed:

The code is as follows: Copy code

# Do not remove the following line, or various programs
# That require network functionality will fail.
127.0.0.1 localhost. localdomain localhost aiteyu
198.46.146.48 aiteyu

The method to add is to use the vi command: vi/etc/hosts

Use the arrow keys to move the cursor to the desired position. After adding the cursor, press ESC to enter the command mode and enter ": wq".

Save and exit, and restart VPS.

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.