March 6th, 2013, 11:14 PM
Help with Flask-Mail using Heroku + Mailgun
I have been writing a simple app to test how to send emails via an SMTP method (needs to be SMTP to be portable to different SMTP services) using Flask-Mail. For this I am trying to use Mailgun through Heroku, but after much trial, error and research I still cannot seem to get emails to send.
My question is on a similar vein to this question on Stack Overflow called 'Flask on Heroku with MailGun config issues' (I tried to hyperlink but this newly registered account won't allow me to). However, I can see no resolution in the question on SO, other than to use Mailgun's API, which isn't feasible for the project I am working on.
Currently I have the flask/flask-mail code set up as follows (stripped down of course):
Am I missing something? And is there a way to test what is going wrong as the code passes and 'Email Sent' is returned, but no email is sent/received seemingly?
from flask import Flask
from flask.ext.mail import Mail
from flask.ext.mail import Message
app = Flask(__name__)
mail = Mail(app)
msg = Message("Hello",
msg.html = "<b>testing</b>"
return 'Email Sent'
if __name__ == '__main__':
Any help would be appreciated, thanks!
March 7th, 2013, 02:58 AM
I would first verify that these environment variables are correct by printing them out.
Originally Posted by FlaskGuy
Have you verified that you can send mail from the command line of the server you're running on?