【发布时间】:2021-07-25 18:21:39
【问题描述】:
我正在尝试使用 Python 通过 Gmail 发送电子邮件。但是,我想添加已在我的 Gmail 设置中指定的电子邮件签名和字体大小(大号)。以下是发送电子邮件的代码;我需要添加什么来完成这个要求?
代码如下:
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
subject = "Offer"
message = "My offer is 2 dollars"
email = "sender@gmail.com"
password ='mypassword'
send_to_email = "recipient@gmail.com"
msg = MIMEMultipart()
msg["From"] = email
msg["To"] = send_to_email
msg["Subject"] = subject
msg.attach(MIMEText(message, 'plain'))
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(email, password)
text = msg.as_string()
server.sendmail(email, send_to_email, text)
server.quit()
【问题讨论】: