Missing email on 500 ISE w/ Django

The OpenShift forums have been retired.
You can still read and search them, but for help, please post a question on Stack Overflow.

Hi guys, previously (1 month ago or so) I would get an email sent to my when my application hits internal server error. It is a Django app and I would get the full python traceback in my mailbox. The messages were sent to the address configured in setup.py (I believe) in the author_email field.

After the latest updates to Express I'm not getting these emails anymore. I just made a change to the app to trigger ISE and I got no email at all.

Hi;

Are you using an external mail relay server to handle emails coming from Amazon EC2? The receiving server may have blacklisted emails coming from Amazon.

Please see https://www.openshift.com/blogs/outbound-mail-ports-are-now-open-for-bus... for more information.

Thanks;
~Nam

Hi Nam,
I'm not using anything. If this functionality was not setup by Red Hat then I guess it was a nice side effect.

I have my e-mail correctly configured in setup.py and in Django's settings.py (as the admin owner). Plus this is the same address which is tied to my username.

I have DEBUG=False in settings.py so whenever something bad happened OpenShift will return 500 ISE. I used to get emails when that happened with the full Python traceback inside. That was in the beginning when I was rapidly changing my app and it will hit these issues.

In the mean time OpenShift got lots of new updates and my code became more mature. Recently I hit a few ISEs and didn't get the emails for those.

Emailing on 500 errors was very useful because I don't have the habit to look at error_log and even if I do, I will have to do it on a regular basis to spot issues which may be hidden in some edge use case.

If you are not sure what caused this functionality then I guess I will have to file a RFE in Bugzilla. Just let me know if I have to.

Hi Alexander;

The best way to determine if emails are being blocked/blacklisted, is by ssh'ing into the host and running sendmail.

For example:
>> sendmail -t < mail.txt
where contents of mail.txt:
Date: Fri Mar 16 11:27:00 2012
To: nam.duong@gmail.com
Subject: test from testphp node
From: nam.duong@gmail.com
My bologna has a first name

I noticed that this works initially, but is sending the email to my junk folder. Furthermore, after a set of these, gmail will block the sender thinking it's spam. To work around it, you will need to set up a relay mail server where you have full control such that emails coming from Amazon will not be blacklisted.

Thanks;
~Nam

We observed quite a lot of variance on whether a message from an EC2 address would be blocked at the receiving end. This seemed to change over time as well as by the server and recipient.

Frequently, recipient mail servers would just refuse the connection altogether and we wouldn't even get a message in our spam folders (blacklisting).

We even observed a certain large public mail service lock our testing account because EC2 tried to log into it a few times.

The only reliable way to get mail out of EC2 is via an authenticated relay willing to accept connections from EC2.

Check with your mail server admins to see if they are willing to set up a separate account for your application to log in from EC2 and send mail. Another alternative is Amazon SES. We don't (*yet*) have an API to set this up for you but can assist in doing it by hand.

Also receiving

"Delivery Status Notification -Failure"

"Your message did not reach some or all of the intended recipients." even configured SMTP and using relay server.

Alexander,

Did you figure this out? I am experiencing a similar issue. I initially did receive Django 500 errors, but haven't been receiving for the last few months. I am finally getting around to figuring out why. I can run an interactive python shell and send mail manually, and that goes through just fine. That would seem to indicate it is not a blacklisting issue.

Thanks, Lane

Hi Lane, I fixed this at some point in time, here is my relevant configuration.

Make sure ADMINS setting lists valid addresses.

# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}
 
# Used for error reporting to admins
# NB: needs to be verified in Amazon SES
SERVER_EMAIL = 'django@dif.io'
 
# Amazon Simple Email Service settings
# in IAM difio-ses user
AWS_SES_ACCESS_KEY_ID = 'xxxxxxxxxxxx'
AWS_SES_SECRET_ACCESS_KEY = 'xxxxxxxx'
EMAIL_BACKEND = 'django_ses.SESBackend'

NB: I am using Amazon SES to send emails both to users and to sitre admins. I think the above is all needed configuration to get this working. Let me know if this worked for you.

Alexander,

I happen to be using amazon ses already, so it was quick to test your suggestion and it works perfectly for me.

Thanks, Lane

I'm also having problems with application mail delivery, but from a Drupal 7 instance. Drupal event logs record email being sent, and there's nothing in the PHP log.

I set a dependency for Mail and git push'd as instructed, and verified that pear mail and dependencies are installed. I tried following Nam's advice of testing from the gear CLI using sendmail, and still haven't received anything. How can we review sendmail's log file since we don't have permissions for the /var/log directory?

I'm getting really frustrated with OpenShift, and thinking of migrating my customer elsewhere.

what is your application url?

Has the email still not come through? Sometimes the mail queue gets backed up and it can take awhile for mails to start showing up at their destinations.