邮件发送的几种方式

admin 2022年1月6日01:32:28评论79 views字数 1124阅读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 <mailgun@yourdomain>",
"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

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月6日01:32:28
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   邮件发送的几种方式http://cn-sec.com/archives/721797.html

发表评论

匿名网友 填写信息