6

I am deploying a Django project on an ubuntu stack with a postfix SMTP mail server, hosted on Amazon's EC2. I can send out email from the server using the Linux mail program. But when I try to send email using django.core.mail.send_mail, the email is never received.

Here are my settings:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

I left everything else as default.

I tried

python manage.py shell

Then in the shell, I did

from django.core.mail import *
send_mail(
    'TEST',
    'THIS IS A TEST',
    '[email protected]',
    ['[email protected]'],
    fail_silently=False,
    )

This returns 1, but I never received any message at the destination ('[email protected]' in the example).

Is there a tutorial on how to configure a SMTP server to work with Django's mail system? Thanks.

1
  • I assume that you did specify your EMAIL_HOST, EMAIL_PORT, EMAIL_HOST_USER and EMAIL_HOST_PASSWORD in your settings.py right? And for the email port, you did open your port for smtp under ec2's security group? Smtp port usually defaults to 25 if you left it as default during your postfix configuration. Commented Sep 7, 2011 at 16:36

1 Answer 1

1

I assume that you did specify your EMAIL_HOST, EMAIL_PORT, EMAIL_HOST_USER and EMAIL_HOST_PASSWORD in your settings.py right?

A detailed explanation of how the default django.core.mail.backends.smtp.EmailBackend works is explained - https://docs.djangoproject.com/en/dev/topics/email/ https://docs.djangoproject.com/en/dev/topics/email/#smtp-backend

And specifically for your email port, you did open your port for smtp under EC2's security group? SMTP port usually defaults to 25 if you left it as default during your postfix configuration and it is important that you have opened up that port when you created your EC2 instance.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.