I wanted to send an email with Django(1.5
), in my console it looked like the following:
In [30]: send_mail("bla", "here it is", "from_address@gmail.com",
["to_address@gmail.com"], fail_silently=False)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: bla
From: from_address@gmail.com
To: to_address@gmail.com
Date: Sat, 14 Dec 2013 11:56:37 -0000
Message-ID: <20131214115637.4720.60719@my_username-E531>
here it is
-------------------------------------------------------------------------------
Out[30]: 1
Eventually I found the problem was caused because EMAIL_BACKEND
(containing django.core.mail.backends.smtp.EmailBackend
) in settings.common.py
was being overwritten by EMAIL_BACKEND
(containing django.core.mail.backends.console.EmailBackend
) in settings.dev.py
with a different value.
The only explicit clue I had that something went wrong was Out[30]: 1
, as I understand an exit status of an unsuccessful run of a process.
The return value you see is the number of messages processed. From the django.core.mail.backends.base.BaseEmailBackend.send_messages()
method:
def send_messages(self, email_messages): """ Sends one or more EmailMessage objects and returns the number of email messages sent. """
The backend you are using, even though it is the wrong one, is indicating it sent 1 message.
If this is the django.core.mail.console.EmailBackend()
backend, that just means 1 message was written to sys.stdout
, but otherwise not forwarded to a SMTP server.