python伪造邮件发件地址_如何在python电子邮件脚本中的发件人地址之前添加发件人名称...

这是我的代码

# Import smtplib to provide email functions

import smtplib

# Import the email modules

from email.mime.multipart import MIMEMultipart

from email.mime.text import MIMEText

# Define email addresses to use

addr_to = 'user@outlook.com'

addr_from = 'user@aol.com'

# Define SMTP email server details

smtp_server = 'smtp.aol.com'

smtp_user = 'user@aol.com'

smtp_pass = 'pass'

# Construct email

msg = MIMEMultipart('alternative')

msg['To'] = addr_to

msg['From'] = addr_from

msg['Subject'] = 'test test test!'

# Create the body of the message (a plain-text and an HTML version).

text = "This is a test message.\nText and html."

html = """\

"""

# Record the MIME types of both parts - text/plain and text/html.

part1 = MIMEText(text, 'plain')

part2 = MIMEText(html, 'html')

# Attach parts into message container.

# According to RFC 2046, the last part of a multipart message, in this case

# the HTML message, is best and preferred.

msg.attach(part1)

msg.attach(part2)

# Send the message via an SMTP server

s = smtplib.SMTP(smtp_server)

s.login(smtp_user,smtp_pass)

s.sendmail(addr_from, addr_to, msg.as_string())

s.quit()

我只是希望收到的电子邮件在发件人电子邮件地址之前显示发件人姓名,如下所示:sender_name

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值