Log in

registration email puzzle

  • 20 Aug '14

And one more question... Please let me know if this would be more appropriate at Stackoverflow (or somewhere else again).

I'm having a bit of trouble getting a spirit instance to send emails. (Apparently setting up email is a bit of a hurdle for novices.) I did some Postmark configuation in the site's settings.py file like this.

EMAIL_BACKEND = 'postmark.django_backend.EmailBackend'
POSTMARK_API_KEY = os.environ['POSTMARK_API_KEY']
POSTMARK_SENDER = 'the.robot@example.com'
POSTMARK_TEST_MODE = False
POSTMARK_TRACK_OPENS = False
DEFAULT_FROM_EMAIL = POSTMARK_SENDER
SERVER_EMAIL = POSTMARK_SENDER

On the local server, the registration emails, etc., now go out fine. (Though this seemed to require changing the def sender(...) in utils/user/email.py so that "site" refers to "example.com" rather than to the result of get_current_site(request).)

Also, after deploying to heroku and running python there, I can send emails using send_mail(...) after importing settings from django.config and send_mail from django.core.mail.

When I load the forum in a browser and try to send activation email, the next page says to expect a message as usual. But the message doesn't show up, and the Postmark site doesn't register that it was sent.

Sorry if this is not quite the place for the novice technical query.

Best,

Max

  • 20 Aug '14

Thanks!

It looks as though the Postmark add-on is already installed. At least, running "heroku addons:add postmark" gives "That add-on plan is already installed". When I do

heroku run python

from django.config import settings
from django.core.mail import send_mail
send_mail('test from heroku','body',settings.DEFAULT_FROM_EMAIL,['the.robot@example.com'],fail_silently=False)

then the Postmark server sends the message. It's just when I request the activation message at e.g.

http://www.example.com/blahblah/user/login/

that it isn't sent.

Just regarding the third link above: is the idea to replace the spirit user registration system with that provided by the django-registration package? Or do these work together? (Sorry if that is a silly question.)

4na4silvestris
  • 20 Aug '14

You need to follow instructions from a second link, e.g.
https://devcenter.heroku.com/articles/postmark#sending-emails-in-python

4na4silvestris
  • 20 Aug '14

Or try to install and configure Django Postmark:
https://github.com/dstufft/django-postmark

nitelyEsteban Castro Borsani
  • 20 Aug '14

There is a try ... except block around the send() call in utils.user.email.sender(), so if there is an error is being logged to nowhere, since you won't receive an email in case of exceptions (coz your email backend doesn't work ). You may try logging errors to a file by changing the settings.LOGGING setting, or remove the try ... except block, so you can see the traceback in the browser (set DEBUG=True first).

  • 20 Aug '14

I'd set up Python-Postmark (following the instructions on that page, https://devcenter.heroku.com/articles/postmark#sending-emails-in-python). And it seems to work, in the heroku installation of the django site. Just the darn registration emails. Well, I'll futz around a little more, maybe try swapping the auth system. Thanks again,

M

Reply