Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#2897 closed enhancement (fixed)

[patch] Support TLS for django mail

Reported by: bjorn@… Owned by: Adrian Holovaty
Component: Core (Mail) Version:
Severity: normal Keywords:
Cc: jesse.lovelace@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This patch enables a new settings variable EMAIL_TLS, which if present and evaluates to non-zero, will make Django send emails using TLS (SSL). I don't have a local SMTP server set up on my laptop, so with this I can do development on the laptop and send emails via our office SMTP server which (sanely so) requires an encrypted connection.

Attachments (3)

django-mail-tls-patch.txt (1.8 KB) - added by bjorn@… 10 years ago.
Patch to enable TLS support for django.core.mail.send*mail
django-mail-tls-patch.2.txt (2.3 KB) - added by bjorn@… 10 years ago.
New version w/ default config variable global_settings
django-mail-tls-patch.3.txt (3.2 KB) - added by mail@… 10 years ago.
modified and updated patch against rev 4815, works here with a hosted Google account

Download all attachments as: .zip

Change History (12)

Changed 10 years ago by bjorn@…

Attachment: django-mail-tls-patch.txt added

Patch to enable TLS support for django.core.mail.send*mail

Changed 10 years ago by bjorn@…

Attachment: django-mail-tls-patch.2.txt added

New version w/ default config variable global_settings

comment:1 Changed 10 years ago by Ramiro Morales

Summary: Support TLS for django mail[patch] Support TLS for django mail

Adding the [patch] prefix to the Summary (and at the same time testing if the whitelisting of IP adddresses in Akismet works :)

comment:2 Changed 10 years ago by Adrian Holovaty

Resolution: wontfix
Status: newclosed

This is outside the scope of Django's (very simple) mail-sending framework. The mail-sending framework intentionally does not do many things; for more intensive applications, you can just use Python's smtplib.

comment:3 Changed 10 years ago by James Wheare <django@…>

Component: Core frameworkdjango.core.mail
Triage Stage: UnreviewedDesign decision needed

This is a problem if your host requires all SMTP connections to be via SSL. Since Django itself relies on this (very-simple) framework to send out broken link and 500 emails, it would be nice if it were equipped to handle this particular setup rather than choke on an smtplib error that my own app can't easily work around.

comment:4 Changed 10 years ago by boxed@…

The patch in #3560 gives support for gmail specificially, the patch in this issue does not.

I am with James on this. Plus, for my own domain I am using googles hosted email service, so I have no longer any access to a non-encrypted SMTP server. Considering google is making this service free this will only be more common in the future I predict.

comment:5 Changed 10 years ago by James Wheare <django@…>

Resolution: wontfix
Status: closedreopened

Changed 10 years ago by mail@…

Attachment: django-mail-tls-patch.3.txt added

modified and updated patch against rev 4815, works here with a hosted Google account

comment:6 Changed 10 years ago by anonymous

Cc: jesse.lovelace@… added

comment:7 Changed 10 years ago by Malcolm Tredinnick

Resolution: fixed
Status: reopenedclosed

(In [5144]) Fixed #2897 -- Added support for TLS connections to email handling. This means
servers like Google's SMTP server can now be used for admin emails.

comment:8 Changed 8 years ago by aronchi

My settings: EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'test@…' EMAIL_HOST_PASSWORD = 'test' EMAIL_PORT = 587 EMAIL_USE_TLS = True

my view:

email = EmailMessage(subject, t.render(c), to = [settings.CONTACT_FORM_TO],from_email='pippo@pluto')

In my gmail I receive the emails from my google identity, not the from I set.

Is there any solution?

comment:9 in reply to:  8 Changed 8 years ago by Karen Tracey

Replying to aronchi:
You'd be better off posting your question on django-users. Very few people are going to notice a question posted in a closed ticket. Personally I'd guess the Google SMTP server does not allow you to lie about the from field, but you're more likely to find someone who knows for sure on the mailing list than here.

Note: See TracTickets for help on using tickets.
Back to Top