How to send an email with Gmail as provider using Python?

后端 未结 14 1663
感情败类
感情败类 2020-11-22 03:29

I am trying to send email (Gmail) using python, but I am getting following error.

Traceback (most recent call last):  
File \"emailSend.py\", line 14, in <         


        
14条回答
  •  清酒与你
    2020-11-22 03:37

    There is a gmail API now, which lets you send email, read email and create drafts via REST. Unlike the SMTP calls, it is non-blocking which can be a good thing for thread-based webservers sending email in the request thread (like python webservers). The API is also quite powerful.

    • Of course, email should be handed off to a non-webserver queue, but it's nice to have options.

    It's easiest to setup if you have Google Apps administrator rights on the domain, because then you can give blanket permission to your client. Otherwise you have to fiddle with OAuth authentication and permission.

    Here is a gist demonstrating it:

    https://gist.github.com/timrichardson/1154e29174926e462b7a

提交回复
热议问题