因此,我编写了这段Python代码,它使用gmail帐户发送电子邮件,我不知道如何添加CC和BCC。有人能帮我吗
import smtplib
from email.message import EmailMessage
def get_cred(PATH):
with open(PATH, "r") as f:
file = f.readlines();
login = file[0]
password = file[1]
return login, password
def sendemail(message):
login, password = get_cred("c:\\mypath")
server = smtplib.SMTP("smtp.gmail.com", 587)
server.ehlo()
server.starttls()
server.login(login, password)
server.send_message(message)
server.quit()
sender = get_cred("c:\\mypath")
message = EmailMessage()
message['Subject'] = 'test'
message['From'] = sender
message['To'] = 'reciever_email@gmail.com'
message.set_content("test")
sendemail(message)
你可以试试这个
相关问题 更多 >
编程相关推荐