Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- from email.mime.text import MIMEText
- def sendTextMail(subject, to_addrs, content):
- from_addr = 'mock@xxserver.com'
- passwd = 'psd'
- msg = MIMEText('hello, send by Python...', 'plain', 'utf-8')
- msg['Subject'] = subject
- msg['From'] = from_addr
- msg['To'] = to_addrs
- s = smtplib.SMTP_SSL("smtp.server.com", 465)
- # s = smtplib.SMTP()
- s.set_debuglevel(1)
- s.login(from_addr, passwd)
- s.sendmail(from_addr, to_addrs, msg.as_string())
- print("Success")
- s.quit()
- subject = "subject 1"
- to_addrs = 'to@email.com'
- content = 'something'
- sendTextMail(subject, to_addrs, content)
- reply: b'250-smtp.aliyun-inc.comrn'
- reply: b'250-8BITMIMErn'
- reply: b'250-AUTH=PLAIN LOGIN XALIOAUTHrn'
- reply: b'250-AUTH PLAIN LOGIN XALIOAUTHrn'
- reply: b'250-PIPELININGrn'
- reply: b'250 DSNrn'
- reply: retcode (250); Msg: b'smtp.aliyun-inc.comn8BITMIMEnAUTH=PLAIN LOGIN XALIOAUTHnAUTH PLAIN LOGIN XALIOAUTHnPIPELININGnDSN'
- send: 'AUTH PLAIN AHJvb3RAd2hvb28udG9wAFN5cTIwMDkwMDEzMDEwNw==rn'
- reply: b'235 Authentication successfulrn'
- reply: retcode (235); Msg: b'Authentication successful'
- send: 'mail FROM:<mock@xxserver.com>rn'
- reply: b'250 Mail Okrn'
- reply: retcode (250); Msg: b'Mail Ok'
- send: 'rcpt TO:<to@email.com>rn'
- reply: b'250 Rcpt Okrn'
- reply: retcode (250); Msg: b'Rcpt Ok'
- send: 'datarn'
- reply: b'354 End data with <CR><LF>.<CR><LF>rn'
- reply: retcode (354); Msg: b'End data with <CR><LF>.<CR><LF>'
- data: (354, b'End data with <CR><LF>.<CR><LF>')
- send: b'Content-Type: text/plain; charset="utf-8"rnMIME-Version: 1.0rnContent-Transfer-Encoding: base64rnSubject: subject 1rnFrom: mock@xxserver.comrnTo: to@email.comrnrnaGVsbG8sIHNlbmQgYnkgUHl0aG9uLi4urn.rn'
- **Success**
- reply: b'250 Data Ok: queued as freedomrn'
- reply: retcode (250); Msg: b'Data Ok: queued as freedom'
- data: (250, b'Data Ok: queued as freedom')
- send: 'quitrn'
- reply: b'221 Byern'
- reply: retcode (221); Msg: b'Bye'
Add Comment
Please, Sign In to add comment