In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
#! / usr/bin/env python #-*-coding:utf-8-*-import smtplibfrom smtplib import SMTP_SSLfrom email.mime.text import MIMETextfrom email.header import Header# defines a dictionary store to send and receive Email account password subject, content and coding related information mail_info = {"from": "w673004708@163.com", # sender "to": "673004708@qq.com", # recipient "hostname": "smtp.163.com", # 163smtp server "username": "w673004708@163.com", # email account "password": "*" # email password This password is 163 mailbox authorization code "subject": "Test sending email", # email subject "mail_text": "I just want to test whether the email can be sent", # email content "mail_encoding": "utf-8" # Encoding format} # send content msg=MIMEText (mail_info ['mail_text'], "plain") in MIME format Mail_info ['mail_encoding']) # set the message subject msg [' Subject'] = Header (mail_info ['subject']) Mail_info ['mail_encoding']) # set email sender msg ["from"] = mail_info ["from"] # set recipient msg ["to"] = mail_info ["to"] # create a smtp object smtp=SMTP_SSL () # smtp.set_debuglevel (1) try:# connect to qq smtp server smtp.connect (mail_info [' hostname']) # log in to smtp.login (mail_info ['username']) with account password Mail_info ['password']) # send email smtp.sendmail (mail_info [' from'], mail_info ['to'], msg.as_string ()) # close the mail object smtp.quit () except smtplib.SMTPAuthenticationError as e: print eelse: print "sent successfully"
Note the format of python. The above can be sent directly. The topic and content are fixed.
& &
The following one can pass parameters.
[root@bogon ~] # python mail.py Today's work Migration Server plus Code launch
Sent successfully
[root@bogon ~] #
#! / usr/bin/env python #-*-coding:utf-8-*-import smtplib import sysfrom smtplib import SMTP_SSLfrom email.mime.text import MIMETextfrom email.header import Header# defines a dictionary store to send and receive Email account password subject, content and coding related information subject = sys.argv [1] content = sys.argv [2] mail_info = {"from": "w673004708@163.com", # sender "to": "673004708@qq.com", # recipient "hostname": "smtp.163.com", # qq smtp server "username": "w673004708@163.com" # email account "password": "*", # email password This password is 163 mailbox authorization code "subject": subject, # message subject "mail_text": content,# message content "mail_encoding": "utf-8" # Encoding format} # transfer content msg=MIMEText (mail_info ['mail_text'], "plain", mail_info [' mail_encoding']) # set message subject msg ['Subject'] = Header (mail_info [' subject']) Mail_info ['mail_encoding']) # set email sender msg ["from"] = mail_info ["from"] # set recipient msg ["to"] = mail_info ["to"] # create a smtp object smtp=SMTP_SSL () # smtp.set_debuglevel (1) try:# connect to qq smtp server smtp.connect (mail_info [' hostname']) # log in to smtp.login (mail_info ['username']) with account password Mail_info ['password']) # send email smtp.sendmail (mail_info [' from'], mail_info ['to'], msg.as_string ()) # close the mail object smtp.quit () except smtplib.SMTPAuthenticationError as e: print eelse: print "sent successfully"
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.