Code

Ticket #5248: mail_options.diff

File mail_options.diff, 2.6 KB (added by mmcclain@…, 7 years ago)
Line 
1Index: django/conf/global_settings.py
2===================================================================
3--- django/conf/global_settings.py      (revision 6000)
4+++ django/conf/global_settings.py      (working copy)
5@@ -127,6 +127,9 @@
6 EMAIL_HOST_PASSWORD = ''
7 EMAIL_USE_TLS = False
8 
9+# Optional SMTP mail_options
10+EMAIL_MAIL_OPTIONS = []
11+
12 # List of strings representing installed apps.
13 INSTALLED_APPS = ()
14 
15Index: django/core/mail.py
16===================================================================
17--- django/core/mail.py (revision 6000)
18+++ django/core/mail.py (working copy)
19@@ -107,13 +107,14 @@
20     """
21 
22     def __init__(self, host=None, port=None, username=None, password=None,
23-            use_tls=None, fail_silently=False):
24+            use_tls=None, fail_silently=False, mail_options=[]):
25         self.host = host or settings.EMAIL_HOST
26         self.port = port or settings.EMAIL_PORT
27         self.username = username or settings.EMAIL_HOST_USER
28         self.password = password or settings.EMAIL_HOST_PASSWORD
29         self.use_tls = (use_tls is not None) and use_tls or settings.EMAIL_USE_TLS
30         self.fail_silently = fail_silently
31+        self.mail_options = mail_options or settings.EMAIL_MAIL_OPTIONS
32         self.connection = None
33 
34     def open(self):
35@@ -180,7 +181,8 @@
36         try:
37             self.connection.sendmail(email_message.from_email,
38                     email_message.recipients(),
39-                    email_message.message().as_string())
40+                    email_message.message().as_string(),
41+                   self.mail_options)
42         except:
43             if not self.fail_silently:
44                 raise
45Index: docs/email.txt
46===================================================================
47--- docs/email.txt      (revision 6000)
48+++ docs/email.txt      (working copy)
49@@ -36,6 +36,7 @@
50 .. _EMAIL_HOST_USER: ../settings/#email-host-user
51 .. _EMAIL_HOST_PASSWORD: ../settings/#email-host-password
52 .. _EMAIL_USE_TLS: ../settings/#email-use-tls
53+.. _EMAIL_MAIL_OPTIONS: ../settings/#email-mail-options
54 
55 send_mail()
56 ===========
57Index: docs/settings.txt
58===================================================================
59--- docs/settings.txt   (revision 6000)
60+++ docs/settings.txt   (working copy)
61@@ -426,6 +426,15 @@
62 
63 See also ``EMAIL_HOST_PASSWORD``.
64 
65+EMAIL_MAIL_OPTIONS
66+------------------
67+
68+Default: ``[]``
69+
70+The ESMTP options to use when sending mail to the SMTP server defined in
71+``EMAIL_HOST``.  The ESMTP options vary by MTA.  Example: Passing ['XVERP'] to
72+Postfix, will enable varible envelope return path (VERP) delivery of messages.
73+
74 EMAIL_PORT
75 ----------
76