我能够使用Python和谷歌库(,和)发送电子邮件。我正在尝试获取备用的“发件人”或“回复”地址,但它不起作用。我用于创建消息的代码是这样的:googleapiclientgoogle_auth_oauthlib.flowgoogle.auth.transport.requests
# Returns an e-mail message suitable for submission through the gmail api.
def create_message(sender, to, subject, message_text):
message = MIMEMultipart()
message['to'] = to
#message['from'] = sender
message['from'] = 'derp@nowhere.com'
message['subject'] = subject
message.attach(MIMEText(message_text, 'html'))
return {'raw': base64.urlsafe_b64encode(message.as_string().encode()).decode()}
如您所见,我已经调整了 .发送此邮件时,它来自gmail帐户所有者,而不是“derp”。如何使邮件来自其他地址?frommessage
慕无忌1623718
相关分类