For the past several days I've been trying to send confirmation emails from my GAE app but my GAE email quota has reached its limit, and although I have billing enabled my email quota won't reset for while to come since I just enabled billing.
I've looked into using Mandrill/MailChimp (via wrapper API's) and have got them to send emails from my desktop. However when I use my code in a GAE app and run it on the local dev server or online server they won't send emails because mailsnake, chimpy, etc all require the "requests" python module. So I downloaded the module and properly put it in its location in my app engine project.
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 requests module relies on ssl.py, ssl.py is a python wrapper for _ssl (a c library not supported by app engine python (2.7)).
So I tried putting ssl.c in that location but it didn't work... So now I'm stuck..
I'm thinkink to myself, even if i put ssl.c so the the python ssl wrapper module can use it, another error might come up and I'll never be able to keep up on chasing all the dependencies mailchimp/mandrill python api wrappers need to run on GAE's version of python that are automatically there on my desktops python..
So although I can send emails using my ubuntu python, I can't send them from GAE.
My 1st question is, I was wondering if anyone got a mailchimp/mandrill emailing to work from GAE.
2nd Question is: If there's no other alternatives to what I'm doing to get emails to send from GAE using mandrill/mailchimp how do I install a python module in a GAE project and all of it's dependencies automatically..?
Thanks for any help in advance..
You can directly use Mandrills REST API to send a message.
You can use URL Fetch API to make REST requests and JSON to serialize/deserialize payloads.
Posting the code that worked for me based on @PeterKnego's 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": "[email protected]",
"from_name": "Example Name",
"to": [
{
"email": "[email protected]"
}
]
}
}
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'})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With