邮件发送的几种方式

admin 2022年1月6日01:32:28安全博客 CTF专场评论23 views1124字阅读3分44秒阅读模式

做做笔记

0x1调用第三方邮件服务

0x1.2 mailgun

1
2
3
4
5
6
7
8
9
10
import requests
def send_simple_message():
return requests.post(
"https://api.mailgun.net/v3/yourdomain/messages",
auth=("api", "yourapi"),
data={"from": "JMCTF Admin <[email protected]>",
"to": ["[email protected]"],
"subject": "Hello",
"text": "Testing some Mailgun awesomness!"})
send_simple_message()

0x1.2 qq

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.header import Header
def get_smtp(host, port, username, password):
smtp = smtplib.SMTP_SSL(host, port)
smtp.ehlo()
smtp.login(username, password)
return smtp
def sendmail():
data = {
'host': "smtp.qq.com",
'port': 465
}
data['username'] = "[email protected]"
data['password'] = "*************"

smtp = get_smtp(**data)
msg = MIMEText('Python 邮件发送测试...', 'plain', 'utf-8')
msg['Subject'] = "Message from {0}".format("ctf_name")
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
smtp.sendmail(msg['From'], [msg['To']], msg.as_string())
smtp.quit()
print "Email sent"
sendmail()

0x2 semdmail

1
echo "This is test mail" | sendmail -s 'Test mail' test@qq.com

FROM :blog.cfyqy.com | Author:cfyqy

特别标注: 本站(CN-SEC.COM)所有文章仅供技术研究,若将其信息做其他用途,由用户承担全部法律及连带责任,本站不承担任何法律及连带责任,请遵守中华人民共和国安全法.
  • 我的微信
  • 微信扫一扫
  • weinxin
  • 我的微信公众号
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月6日01:32:28
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                  邮件发送的几种方式 http://cn-sec.com/archives/721797.html

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: