Shell Script Auto-Configure send QQ mail

Source: Internet
Author: User
Tags auth

Every time I write a script under Linux has the ability to send mail, but the configuration under Linux always forget, so this time wrote a small script, record, next time you want to configure the script to run the line. QQ mailbox is used here.

Test environment: CentOS 6.5 x86_64


The script reads as follows:

#!/bin/bash. /etc/init.d/functionsif [ $# -ne 0 ];then     echo  "usage: sh  ' basename $0 '"     exit 1 fifrommail= "[email  protected] ' smtp_host= ' smtp.qq.com ' smtp_auth_user= ' [email protected] ' smpt_auth_password= ' Mdkuasfhnjbrbhdj ' certs_dir=/root/.certsmail_conf=/etc/mail.rccontent= ' cat  $mail _conf |grep  ' Smtp-auth-user "if [ " x$content " != " x "  ];then   action    "' $mail _conf '   file already configured"  /bin/true   exit 1ficat >>  $mail _ conf <<eof set from= $frommailset  smtp= $smtp _hostset smtp-auth-user= $smtp _auth_ userset smtp-auth-password= $smpt _auth_passwordset smtp-auth=loginset smtp-use-starttlsset  ssl-verify=ignoreset nss-config-dir= $certs _direof[ $? -eq 0  ] &&  action  "Configuring $mail_conf Files" &Nbsp;/bin/true [ ! -d  $certs _dir ] && mkdir -p  $certs _ direcho -n | openssl s_client -connect  $SMTP _host:465 | sed -ne   '/-begin certificate-/,/-end certificate-/p '  >  $certs _dir/qq.crtcertutil -a  -n  "Geotrust ssl ca"  -t  "C,"  -d  $certs _dir -i  $certs _dir/ qq.crtcertutil -a -n  "Geotrust global ca"  -t  "C,,"  -d  $certs _dir  -i  $certs _dir/qq.crtcertutil -l -d  $certs _dir[ $? -eq 0  ]  && action  "Generate certificate"  /bin/true


Under root user execution:

SH auto_mail_configure.sh

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8B/2B/wKioL1hGb2PSz5fPAABrjtSQBow777.png-wh_500x0-wm_3 -wmp_4-s_1649197434.png "title=" 1.png "alt=" Wkiol1hgb2psz5fpaabrjtsqbow777.png-wh_50 "/>

Execution complete


Next, execute the following command to test:

echo Hello Word | Mailx-v-S "title" [Email protected]

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/8B/2B/wKioL1hGb9GgFR7CAADbxQeu7_U024.png-wh_500x0-wm_3 -wmp_4-s_3757102619.png "title=" 2.png "alt=" Wkiol1hgb9ggfr7caadbxqeu7_u024.png-wh_50 "/>

See if you have received an email:

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/8B/2F/wKiom1hGcDbgrWAWAAE8XplqvXg043.png-wh_500x0-wm_3 -wmp_4-s_2027472456.png "title=" 3.png "alt=" Wkiom1hgcdbgrwawaae8xplqvxg043.png-wh_50 "/>

This article is from the "Xu Mingjiang blog" blog, make sure to keep this source http://dadaloveyou.blog.51cto.com/703960/1880022

Shell Script Auto-Configure send QQ mail

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.