Gmail authorized Linux Server login using Gmail to send mail

Source: Internet
Author: User

I am a side dish, recently worried about when the server triggers the trigger value by invoking the script to notify the administrator, Google summed up the decision to try it yourself;

    1. First, the system with smtp.gmail.com for the SMTP host, you must set the mailbox authorization server login;

      650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/8A/22/wKiom1goJ3Dh7CNFAACdpHmS-xg812.jpg-wh_500x0-wm_3 -wmp_4-s_3619960510.jpg "title=" 111.jpg "alt=" Wkiom1goj3dh7cnfaacdphms-xg812.jpg-wh_50 "/>

      650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/8A/1E/wKioL1goJ9TwVN88AACIC6L7NAs222.jpg-wh_500x0-wm_3 -wmp_4-s_3580974713.jpg "title=" 222.jpg "alt=" Wkiol1goj9twvn88aacic6l7nas222.jpg-wh_50 "/>


2. The configuration trigger is the calling script;

[[email protected] python]# cat smtp.py#!/usr/bin/python                                                                                                                                                                                                     import smtplib                                                                                                                                                                                                                                import string                                                                                                                                                                                                                                                                                                                                                                                                                                                                       host =   "Smtp.gmail.com"                    #定义  smtp  host subject =  "Test email from python"             #邮件主题FROM  =  "[email protected]"                  #发件人text  =  python  rules them all "            # e-mail content body = string.join (                     #组装sendmail方法的邮件主体内容          "from: %s "  % FROM,           #各段以 "  \r\n  "to separate          "to: %s "  % TO,                                           "subject: %s   " % SUBJECT,                                "",          text                                   ), "\ r \ n")                                                                                                   server = smtplib. SMTP ()                  # Create a  SMTP ( )   Object Server.connect (HOST, "+")                    #通过  connect  Method Connection  smtp  host Server.starttls ()                        #启用安全传输模式server. Login ("[email protected]", "**password**")       #邮箱账号登录校验server. SendMail (from,[to],body)                #邮件发送 


3. Test results:

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/8A/22/wKiom1goKYCAfUrnAACB1Tuquhs073.jpg-wh_500x0-wm_3 -wmp_4-s_2749992358.jpg "title=" 343.jpg "alt=" Wkiom1gokycafurnaacb1tuquhs073.jpg-wh_50 "/>

Gmail authorized Linux Server login using Gmail to send 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.