Code

Opened 8 years ago

Closed 7 years ago

Last modified 6 years ago

#2897 closed enhancement (fixed)

[patch] Support TLS for django mail

Reported by: bjorn@… Owned by: adrian
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@… 8 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@… 8 years ago.
New version w/ default config variable global_settings
django-mail-tls-patch.3.txt (3.2 KB) - added by mail@… 7 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 8 years ago by bjorn@…

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

Changed 8 years ago by bjorn@…

New version w/ default config variable global_settings

comment:1 Changed 8 years ago by ramiro

  • Summary changed from Support TLS for django mail to [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 7 years ago by adrian

  • Resolution set to wontfix
  • Status changed from new to closed

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 7 years ago by James Wheare <django@…>

  • Component changed from Core framework to django.core.mail
  • Triage Stage changed from Unreviewed to Design 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 7 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 7 years ago by James Wheare <django@…>

  • Resolution wontfix deleted
  • Status changed from closed to reopened

Changed 7 years ago by mail@…

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

comment:6 Changed 7 years ago by anonymous

  • Cc jesse.lovelace@… added

comment:7 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from reopened to closed

(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 follow-up: Changed 6 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 6 years ago by kmtracey

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.