linux send mail to 163 or QQ mailbox

                                                           linux send mail to 163 or QQ mailbox

I think there are some concepts that need to be understood before starting to send emails, which may be helpful for later learning.

 

POP3 is the abbreviation of Post Office Protocol 3, the third version of the Post Office Protocol. It specifies how to connect a personal computer to an Internet mail server and an electronic protocol for downloading e-mail. It is the first offline protocol standard for Internet email. POP3 allows users to store mail from the server to the local host (ie their own computer) and delete the mail stored on the mail server. The POP3 server follows POP3. The receiving mail server of the protocol, used to receive e-mails. (It is not a particularly secure protocol, because the mail is stored locally, and there is a copy of the server and the client. No matter which end the hacker hacks, it will cause security problems.)

SMTP

The full name of SMTP is "Simple Mail Transfer Protocol", that is, Simple Mail Transfer Protocol. It is a set of specifications used to transfer mail from the source address to the destination address, and it is used to control the way of mail transfer. The SMTP protocol belongs to the TCP/IP protocol suite, which helps each computer find the next destination when sending or transferring letters. The SMTP server is an outgoing mail server that follows the SMTP protocol. 
  SMTP authentication simply means that you must provide your account name and password before you can log in to the SMTP server, which makes it impossible for those spammers to take advantage of it. 
  The purpose of adding SMTP authentication is to prevent users from being harassed by spam.

IMAP

The full name of IMAP is Internet Mail Access Protocol, which is an interactive mail access protocol. It is one of the standard mail access protocols similar to POP3. The difference is that after IMAP is turned on, the emails you receive from the email client remain on the server, and the operations on the client will be fed back to the server, such as deleting emails, marking as read, etc. The mail will also do the corresponding action. So no matter you log in to the mailbox from the browser or log in to the mailbox from the client software, the emails and status you see are the same. (Only save emails on the server side, the security is greatly improved, hackers can only obtain complete control of the emails only by breaking the server side, especially the acquisition of important attachments will increase the hacker's great difficulty.)


 



 




So, what is on the server side, that is, the 163 mailbox or the QQ mailbox?

 

 

 

 




Linux as a client, what software related to mail does it have?

It is clear that the general distribution has postfix and sendmail (sendmail may not be available in high versions such as centos7)

Postfix was created to replace traditional sendmail. Compared with sendmail, postfix is ​​faster. Performance and stability are better. Nowadays, many mainstream mail services are actually using postfix. When we need a lightweight mail server, postfix is ​​a choice.

1. Postfix is ​​free:
    The scope of postfix wants to be used for is the vast number of Internet users. Attempt to influence most of the e-mail systems on the Internet, so it is free.
2. Faster:
    Postfix is ​​approximately three times faster than sendmail in performance. A desktop PC running postfix can send and receive millions of emails every day.
3. Good compatibility:
    Postfix is ​​compatible with sendmail, so that sendmail users can easily migrate to postfix. Postfix supports /var[/spool]/mail, /etc/aliases, NIS, and ~/.forward files.
   4. More robust:
postfix is ​​designed to still work normally under heavy load. When the system execution exceeds the available memory or disk space, postfix will take the initiative to reduce the number of execution processes. When the number of processed mail grows, the process executed by postfix will not be added.
5. More flexible:
postfix is ​​composed of more than a dozen small programs, and each program has a specific function. You can set the execution parameters of each program through the configuration file.

Of course, postfix is ​​a server, and it has nothing to do with sending emails. I think you have never seen a server sending emails to another server.

Normally, the postfix service is open and running, systemctl status postfix you can see that the service is running, but it has nothing to do with sending emails, so you can ignore it.

The protagonist of sending emails is the following mailx software. As shown below, the mail command is actually mailx, and a soft connection is made.

[root@centos7 ~]# rpm -qa |grep mail
libreport-plugin-mailx-2.1.11-38.el7.centos.x86_64
mailx-12.5-16.el7.x86_64
[root@centos7 ~]# ls -alh /usr/bin/mail
lrwxrwxrwx. 1 root root 5 Jan 23 22:38 /usr/bin/mail -> mailx

If you want to learn more about this command, you can take a look at man mail. About 2200 lines are enough for research.

The show is coming, the method of sending emails is as follows:

vim /etc/mail.rc add the following at the end of this file:

set [email protected]
set smtp=smtp.163.com
set [email protected]
set smtp-auth-password=授权密码
set smtp-auth=login

The second line remains unchanged, if it is a QQ mailbox, just change it to smtp.qq.com. [email protected] is your email address, the authorization password is obtained by scanning the code in the 163 or QQ mailbox setting options, and you must record it first.
 

 

1) No message body

  •   mail -s "Subject" recipient address

 mail -s "test" [email protected]

 

2) There is an email body

  •  mail -s "subject" recipient address <file (mail body.txt)

 mail -s "Mail subject" [email protected] </data/findyou.txt

  •  echo "mail body" | mail -s mail subject recipient address

echo "mail body content" | mail -s "mail subject" [email protected]

  •  cat mail body.txt | mail -s mail subject recipient address 

 cat /data/findyou.txt | mail -s "Mail subject" [email protected]

 

3) With accessories

  •  mail -s "Subject" Recipient address -a Attachment <file (mail body.txt) 

 mail -s "Mail subject" [email protected] -a /data/findyou.tar.gz </data/findyou.txt

 

 to sum up:

Linux sends mail to 163 or QQ mailbox. The first step is to open those two services on the server and obtain the authorization password to log in to the mailbox in the Linux client and write the mail and then send it to the server. Linux is the client. Using mailx to send emails has nothing to do with the postfix service, it can be stopped or not .

[root@centos7 ~]# echo  "my first test" | mail -vs " title" -a anaconda-ks.cfg  [email protected]
Resolving host smtp.163.com . . . done.
Connecting to 220.181.12.15:smtp . . . connected.
220 163.com Anti-spam GT for Coremail System (163com[20141201])
>>> EHLO centos7
250-mail
250-PIPELINING
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2UrSzme8UCa0xDrUUUUj
250-STARTTLS
250 8BITMIME
>>> AUTH LOGIN
334 dXNlcm5hbWU6
>>> c2hpZ3VhbmdmZWlzaGk4MjBAMTYzLmNvbQ==
334 UGFzc3dvcmQ6
>>> Q1hYSkxZWURLVFpUVVNGWQ==
235 Authentication successful
>>> MAIL FROM:<[email protected]>
250 Mail OK
>>> RCPT TO:<[email protected]>
250 Mail OK
>>> DATA
354 End data with <CR><LF>.<CR><LF>
>>> .
250 Mail OK queued as smtp11,D8CowAAnY3Tp3ytgIz2ABg--.61081S2 1613488106
>>> QUIT
221 Bye

 mail -v is to display the detailed sending process. The above uses a combination of commands

Successfully sent screenshot:

 

 

 

 

Guess you like

Origin blog.csdn.net/alwaysbefine/article/details/113829379