Using Mandrill / MailChimp in the Google App Engine to send confirmation emails

Over the past few days, I tried to send confirmation emails from my GAE application, but my GAE email quota has reached its limit, and although I have a billing, my email quota will not reset until it appears like this how I just activated billing.

I studied using Mandrill / MailChimp (via the wrapper API) and got them to send emails from my desktop. However, when I use my code in a GAE application and run it on a local development server or online server, they will not send emails because mailsnake, chimpy, etc. All require a python "request" module. Therefore, I downloaded the module and correctly placed it in my location in the project of my application.

Then I got another error ...

File "/home/ahmad/Dropbox/milsal/requests/packages/urllib3/connectionpool.py", line 83, in set_cert 'CERT_NONE': ssl.CERT_NONE, AttributeError: 'module' object has no attribute 'CERT_NONE' 

Then I realized that the query module relies on ssl.py, ssl.py is the python shell for _ssl (the c library is not supported by the python application (2.7)).

So, I tried putting ssl.c in this place, but it didn’t work ... So now I'm stuck ..

I think of myself, even if I put ssl.c, so that the python ssl shell module can use it, another error may occur, and I can never continue to monitor all the dependencies of mailchimp / mandrill python api wrappers must be run in the python GAE version that are automatically present on my python desktop ..

So, although I can send emails using my ubuntu python code, I cannot send them from GAE.

My first question is: I was wondering if anyone has an email mailchimp / mandrill to work with GAE.

Second question: if there are no other alternatives to what I am doing to send emails with GAE using mandrill / mailchimp, how can I automatically install the python module in a GAE project and all its dependencies ..?

Thanks for any help in advance.

+7
source share
2 answers

You can directly use the Mandrills REST API to send a message .

You can use the URL APIs to make REST and JSON requests to serialize / deserialize payloads.

+4
source

Posting code that worked for me based on @PeterKnego answer:

 from google.appengine.api import urlfetch def sendMandrillEmail(): json_mandrill = { "key": "YOUR_API_KEY", "message": { "html": "<p>Example HTML content</p>", "subject": "Test subject", "from_email": " example@email.com ", "from_name": "Example Name", "to": [ { "email": " example.to@email.com " } ] } } url = "https://mandrillapp.com/api/1.0/messages/send.json" result = urlfetch.fetch(url=url, payload=json.dumps(json_mandrill), method=urlfetch.POST, headers={'Content-Type': 'application/x-www-form-urlencoded'}) 
+2
source

All Articles