django.core.mail - DEFAULT_FROM_EMAIL not employed

588 views
Skip to first unread message

funkazio

unread,
Jan 27, 2009, 10:52:51 AM1/27/09
to Django users
Hi,
I made several tests using 'django.core.mail' with the 'mail_managers
()' function.

OK when using GMAIL smtp with these settings:

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = '587'
EMAIL_HOST_USER = 'my.valid...@gmail.com'
EMAIL_HOST_PASSWORD = 'gmail.pwd'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'my.valid...@gmail.com'

OK but message sent as EMAIL_HOST_USER instead of DEFAULT_FROM_EMAIL
with:

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = '587'
EMAIL_HOST_USER = 'my.valid...@gmail.com'
EMAIL_HOST_PASSWORD = 'gmail.pwd'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'my.valid...@yahoo.com'

and NOT OK (504, '5.5.2 <root@localhost>: Sender address rejected:
need fully-qualified address', 'root@localhost') using my Internet
provider smtp:

EMAIL_HOST = 'smtp.myprovider.com'
EMAIL_PORT = '25'
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = 'my.valid...@gmail.com'

so it seems that DEFAULT_FROM_EMAIL is actually not employed. The from
field is filled with the email EMAIL_HOST_USER when an authenticated
smtp is used, otherwise it is left blank.

Anyone having a solution or this is a bug?
Regards

PS. I have the dame behaviour with django 1.0.2 and django trunk.

Karen Tracey

unread,
Jan 27, 2009, 11:24:16 AM1/27/09
to django...@googlegroups.com
On Tue, Jan 27, 2009 at 10:52 AM, funkazio <funk...@gmail.com> wrote:

Hi,
I made several tests using 'django.core.mail' with the 'mail_managers
()' function.

The doc for this function is (around) here:

http://docs.djangoproject.com/en/dev/topics/email/#django.core.mail.mail_admins

Note it says the "From:" header will be the value of the SERVER_EMAIL setting, which you do not mention below.  I'm assuming this is still at the default root@localhost based on one of the scenarios you mention.


It's not employed when you use the mail_admins or mail_managers function, since they specifically state they set the mail to be from SERVER_EMAIL.

 
The from
field is filled with the email EMAIL_HOST_USER when an authenticated
smtp is used, otherwise it is left blank.

I don't see where it was ever left blank?  You've apparently got some servers that quietly force the mail to be "From" the user that has authenticated (EMAIL_HOST_USER) despite claiming to be From root@localhost, you've got one who refuses to send it as From root@localhost (since it is not fully qualified) in the absence of an authenticated user to use instead (since in that case you did not authenticate to the server).
 

Anyone having a solution or this is a bug?

I don't see a bug. 

Karen
Message has been deleted

funkazio

unread,
Jan 28, 2009, 6:02:35 AM1/28/09
to Django users
Right! Thanks!

The SERVER_EMAIL setting works properly with a NOT-authenticated smtp
server, yet using an authenticated server (at least the one I
tried: Gmail) the SERVER_EMAIL is overridden by the EMAIL_HOST_USER.
Maybe that should be properly verified with several server and
modified or documented in case it is not a gmail-specific behaviour.

Thanks again.

Dave Dash

unread,
Feb 21, 2009, 2:54:14 AM2/21/09
to Django users
I started experiencing this too... I can't tell if this is Gmail or
not. I know I send email via SMTP from Gmail masqueraded with other
aliases. So I feel that something is getting munged. Either in the
mail library or with Gmail's servers.

Dave Dash

unread,
Feb 21, 2009, 2:54:47 AM2/21/09
to Django users
I started experiencing this too... I can't tell if this is Gmail or
not. I know I send email via SMTP from Gmail masqueraded with other
aliases. So I feel that something is getting munged. Either in the
mail library or with Gmail's servers.

On Jan 28, 3:02 am, funkazio <funka...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages