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.