#!/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