Simple analysis of how to use script to automatically send text mail mail _linux shell under Linux

Source: Internet
Author: User
1. Install MSMTP

luther@gliethttp:~$ sudo apt-get install msmtp

2. Edit the configuration script (~/.MSMTPRC is the default profile, or you can specify the profile path using the-C option)

luther@gliethttp:~$ Vim MSMTPRC
#添加如下内容
Defaults
#logfile/home/luther/msmtp.log
Account Luther_test
Host mail.gliethttp.cn
From luther@gliethttp.cn
Auth off
Password 123456789
Account Default:luther_test

3. Remove configuration file Execution permissions-X

luther@gliethttp:~$ chmod MSMTPRC

4. OK, you can send a test message to your mailbox using the following statement, or enter it on stdin, and then Ctrl+d

Perhaps some of the data in the file will be lost, not afraid, when we install mutt after all normal.
luther@gliethttp:~$ msmtp luther@gliethttp.cn-c/HOME/LUTHER/MSMTPRC </vobs/tmp/log.c

5. Then install Mutt

luther@gliethttp:~$ sudo apt-get install mutt

6. Edit the configuration script (~/.muttrc is the default profile, or you can specify the profile path using the-f option)

luther@gliethttp:~$ Vim MUTTRC
#添加如下内容
Set sendmail= "/usr/bin/msmtp-c/HOME/LUTHER/MSMTPRC"
Set Use_from=yes
Set from=admin@gliethttp.cn
Set realname= "Test Admin"
Set editor= "Vim"

7. Send ordinary text and file contents

luther@gliethttp:~$ echo "Test 123abc" | Mutt-f/home/luther/muttrc-s "message header-Test" luther@gliethttp.cn
luther@gliethttp:~$ mutt-f/home/luther/muttrc-s "mail title-Test" Luther@gliethttp.cn </etc/passwd

8. Send attachments (-a option to add attachments, the following example adds passwd and resolv.conf these 2 attachments)

luther@gliethttp:~$ echo "Test 123abc" | Mutt-f/home/luther/muttrc-s "Message headers-Test" luther@gliethttp.cn-a/etc/passwd-a/etc/resolv.conf

9. bcc address and CC cc address send, if multiple mailing address, use comma separated

luther@gliethttp:~$ echo "Test 123abc" | Mutt-f/home/luther/muttrc-s "
Mail title-Test "Luther@gliethttp.cn,luther.ge@163.com-b luther.ge@163.com,luther@gliethttp.cn-c luther.ge@163.com, luther@gliethttp.cn
Related Article

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.