This article summarizes four methods for sending emails in linux. For more information, see this article.
Another method for sending emails in Linux -- sendEmail usage:
Download sendEmail
Wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.55.tar.gz
| The Code is as follows: |
Copy code |
Tar-zxvf sendEmail-v1.55.tar.gz Cd sendEmail-v1.55 Cp sendEmail/usr/local/bin Chmod 0755/usr/local/bin/sendEmail /Usr/local/bin/sendEmail-f 123456@qq.com-t 123456@qq.com-s smtp.qq.com-u ""-xu username-xp 123456-m ", this is the content" |
Explanation:
-F indicates the sender's email address.
-T indicates the recipient's email address.
-S indicates the domain name or ip address of the SMTP server
-U indicates the subject of the email.
-Xu indicates the SMTP authentication user name
-Xp indicates the password for SMTP verification. (Note that this password seems to be restricted. For example, I use d! 5neyland cannot be correctly identified)
-M indicates the mail content
Other methods
You can use the mail command to send emails in the following three ways:
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 of mail. welcome to www. mzone. cc |
The first line is the input command,-s indicates the subject of the mail, followed by the admin@mzone.cc is the recipient of the mail, enter this line of command and press enter, will enter the body of the mail writing, we can enter any text, such as the above two lines. After entering the body of the email, press CTRL + D to complete the input. At this time, you will be prompted to enter the Cc address, that is, the Cc address. If you do not press enter, the email will be sent.
2. Use MPs queues to send emails
| The Code is as follows: |
Copy code |
| Echo "hello, this is the content of mail. welcome to www. mzone. cc" | mail-s "Hello from mzone. cc by pipe" admin@mzone.cc |
You can use the pipeline to directly input this line of command to send the mail. The echo is the mail body.
3. Use files to send emails
| The Code is as follows: |
Copy code |
| Mail-s "Hello from mzone. cc by file" admin@mzone.cc <mail.txt |
With the imperative, we can send the contents of the mail.txt file to the admin@mzone.cc as the mail content