Python Mail send

Source: Internet
Author: User

#!/usr/bin/env python
#-*-Coding:utf-8-*-
# @Time: 2018-01-15 20:40
# @Author: HHJ
# @Site:
# import Collections
#

Import Smtplib
From Email.mime.textImport Mimetext
# from Email.utils import formataddr
Import Sys

DEF Mail (cont):
RET =True
Try
msg = Mimetext (cont,' Plain ',' Utf-8 ')
msg[' From '] ="[Email protected]"
msg[' to '] ="[Email protected]"
msg[' Subject '] =Topic

Server = Smtplib. Smtp_ssl ("Smtp.qq.com",465)
Server.login ("[Email protected]","Authorization Code * * *")
Server.sendmail (' [email protected] ', [' [email protected] ',], msg.as_string ())
Server.quit ()
ExceptException:
RET =False
return ret


def main ():
Cont =""
While cont=="":
Cont = Input ("Please enter message content:")
Else:
Ret=mail (cont)
if ret==False:
Print ("message sent failed!") ")
Else:
print ("Mail sent successfully!") ")
If __name__==' __main__ ':
Main ()

Python Mail send

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.