Shell Script Implementation example of automatic sending mail _linux shell

Source: Internet
Author: User

1, edit the user's home directory of the. muttrc file, set the letter environment.

Copy Code code as follows:

# CAT/ROOT/.MUTTRC
Set Envelope_from=yes
Set from=owinux@sina.cn
Set Realname= "Owinux"
Set Use_from=yes
Set Rfc2047_parameters=yes
Set charset= "Utf-8"

2, the letter script

Copy Code code as follows:

# Cat Automail.sh
#!/bin/sh
# automail.sh
Dir=/root/owinux
mailcontent= $DIR/mailcontent
> "$mailcontent"
Echo-e "Owinux, hello!\n" >> $mailcontent
Echo-e "\ t attachment for ' date +%y-%m-%d ' Equipment daily inspection report, please check. ">> $mailcontent
Cat Mailcontent | /usr/bin/mutt-s "Equipment Daily inspection report"-a/root/owinux/report.xls owinux@126.com-c owinux@yeah.net-c owinux@sina.com

3. Brief description:

-S: Specify topic
-A: Accessories
-C: CC, need to use more than one-c option

Use the above letter environment to ensure that when the page view the message, the attachment name does not appear garbled.
where the. Muttrc's "set from" can be arbitrarily set, can be non-existent email address, of course, the best.
Like what:

Copy Code code as follows:

Set from=abc@owinux.com

However, it is not the correct e-mail address you set up to be able to send success.

Copy Code code as follows:

Set from=owinux@126.com

I registered a new owinux@126.com, then set the set from to Owinux@126.com, without success.
The reason is that 126 mailbox reported a MI:SPF error, connect to 126 corporate Retreat Letter FAQ? Found

Copy Code code as follows:

MI:SPF Letter IP is not sent to the domain of the SPF license.

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.