1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > python发邮件被认定为垃圾邮件_使用Python登陆QQ邮箱发送垃圾邮件 简单实现

python发邮件被认定为垃圾邮件_使用Python登陆QQ邮箱发送垃圾邮件 简单实现

时间:2020-08-03 19:58:53

相关推荐

python发邮件被认定为垃圾邮件_使用Python登陆QQ邮箱发送垃圾邮件 简单实现

参考:Python爱好者 知乎文章

需要做的是:

1.邮箱开启SMTP功能

2.获取授权码

上述两步百度都有。

源码:

#!/usr/bin/env python

from email.mime.text import MIMEText

from email.header import Header

from smtplib import SMTP_SSL

# QQ mail smtp server

host_server = ''

# sender QQ

sender_qq = '952693358'

# pwd

pwd = '*****' # 授权码

# sender qqmail

sender_qq_mail = '952693358@'

# receiver QQ

receiver = '952693358@'

# content

mail_content = 'Hi, you are being attacked!'

# title

mail_title = 'Hello'

# SSL login

smtp = SMTP_SSL(host_server)

smtp.set_debuglevel(1) # debug

smtp.ehlo(host_server)

smtp.login(sender_qq, pwd)

msg = MIMEText(mail_content, "plain", 'utf-8')

msg['Subject'] = Header(mail_title, 'utf-8')

msg['From'] = sender_qq_mail

msg['To'] = receiver

smtp.sendmail(sender_qq_mail, receiver, msg.as_string())

smtp.quit()

sh-3.2# ./qqmailattack.py

send: 'ehlo \r\n'

reply: '250-\r\n'

reply: '250-PIPELINING\r\n'

reply: '250-SIZE 73400320\r\n'

reply: '250-AUTH LOGIN PLAIN\r\n'

reply: '250-AUTH=LOGIN\r\n'

reply: '250-MAILCOMPRESS\r\n'

reply: '250 8BITMIME\r\n'

reply: retcode (250); Msg:

PIPELINING

SIZE 73400320

AUTH LOGIN PLAIN

AUTH=LOGIN

MAILCOMPRESS

8BITMIME

send: 'AUTH PLAIN ADk1MjY5MzM1OABxcmFzdGl1cmNicXViY2ln\r\n'

reply: '235 Authentication successful\r\n'

reply: retcode (235); Msg: Authentication successful

send: 'mail FROM:<952693358@> size=203\r\n'

reply: '250 Ok\r\n'

reply: retcode (250); Msg: Ok

send: 'rcpt TO:<952693358@>\r\n'

reply: '250 Ok\r\n'

reply: retcode (250); Msg: Ok

send: 'data\r\n'

reply: '354 End data with .\r\n'

reply: retcode (354); Msg: End data with .

data: (354, 'End data with .')

send: 'Content-Type: text/plain; charset="utf-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: base64\r\nSubject: =?utf-8?q?Hello?=\r\nFrom: 952693358@\r\nTo: 952693358@\r\n\r\nSGksIHlvdSBhcmUgYmVpbmcgYXR0YWNrZWQh\r\n.\r\n'

reply: '250 Ok: queued as \r\n'

reply: retcode (250); Msg: Ok: queued as

data: (250, 'Ok: queued as')

send: 'quit\r\n'

reply: '221 Bye\r\n'

reply: retcode (221); Msg: Bye

Hint:MIMEText函数中的第二个参数为plain时,发送的是text文本,如果为html,则能发送网页格式文本。

.3.12

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。