如何在python中接收和发送电子邮件?各种"邮件服务器".
我正在研究制作一个应用程序,听取它是否收到发送到foo@bar.domain.com的电子邮件,并向发件人发送电子邮件.
现在,我能在python中完成所有这些,最好是使用第三方库吗?
我正在尝试从我的gmail api代码中调用,以便我可以创建草稿,但我无法弄清楚从哪里获得"授权的Gmail API服务实例".这是我的代码:
def CreateDraft(service, user_id, message_body):
CreateDraft('SERVICE THING NEEDS TO BE HERE','me','thisisbody')
"""Create and insert a draft email. Print the returned draft's message and id.
Args:
service: Authorized Gmail API service instance.
user_id: User's email address. The special value "me"
can be used to indicate the authenticated user.
message_body: The body of the email message, including headers.
Returns:
Draft object, including draft id and message meta data.
"""
try:
message = {'message': message_body}
draft = service.users().drafts().create(userId=user_id, body=message).execute()
print 'Draft …Run Code Online (Sandbox Code Playgroud)