Changeset 2548
- Timestamp:
- 03/22/06 13:47:15 (3 years ago)
- Files:
-
- django/trunk/AUTHORS (modified) (3 diffs)
- django/trunk/django/conf/global_settings.py (modified) (1 diff)
- django/trunk/django/core/mail.py (modified) (4 diffs)
- django/trunk/docs/email.txt (modified) (4 diffs)
- django/trunk/docs/settings.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/AUTHORS
r2476 r2548 57 57 Baishampayan Ghose 58 58 Espen Grindhaug <http://grindhaug.org/> 59 Gustavo Picon60 59 Brant Harris 61 60 hipertracker@gmail.com … … 69 68 Garth Kidd <http://www.deadlybloodyserious.com/> 70 69 Sune Kirkeby <http://ibofobi.dk/> 70 Bruce Kroeze <http://coderseye.com/> 71 71 lakin.wecker@gmail.com 72 72 Stuart Langridge <http://www.kryogenix.org/> … … 89 89 pgross@thoughtworks.com 90 90 phaedo <http://phaedo.cx/> 91 Gustavo Picon 91 92 Luke Plant <http://lukeplant.me.uk/> 92 93 plisk django/trunk/django/conf/global_settings.py
r2536 r2548 88 88 EMAIL_HOST = 'localhost' 89 89 90 # Optional SMTP authentication information for EMAIL_HOST. 91 EMAIL_HOST_USER = '' 92 EMAIL_HOST_PASSWORD = '' 93 90 94 # List of strings representing installed apps. 91 95 INSTALLED_APPS = () django/trunk/django/core/mail.py
r1798 r2548 1 1 # Use this module for e-mailing. 2 2 3 from django.conf.settings import DEFAULT_FROM_EMAIL, EMAIL_HOST, EMAIL_SUBJECT_PREFIX 3 from django.conf.settings import DEFAULT_FROM_EMAIL, EMAIL_HOST, EMAIL_SUBJECT_PREFIX, EMAIL_HOST_USER, EMAIL_HOST_PASSWORD 4 4 from email.MIMEText import MIMEText 5 5 import smtplib … … 15 15 MIMEText.__setitem__(self, name, val) 16 16 17 def send_mail(subject, message, from_email, recipient_list, fail_silently=False ):17 def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=EMAIL_HOST_USER, auth_password=EMAIL_HOST_PASSWORD): 18 18 """ 19 19 Easy wrapper for sending a single message to a recipient list. All members 20 20 of the recipient list will see the other recipients in the 'To' field. 21 21 """ 22 return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently )22 return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently, auth_user, auth_password) 23 23 24 def send_mass_mail(datatuple, fail_silently=False ):24 def send_mass_mail(datatuple, fail_silently=False, auth_user=EMAIL_HOST_USER, auth_password=EMAIL_HOST_PASSWORD): 25 25 """ 26 26 Given a datatuple of (subject, message, from_email, recipient_list), sends … … 28 28 29 29 If from_email is None, the DEFAULT_FROM_EMAIL setting is used. 30 If auth_user and auth_password are set, they're used to log in. 30 31 """ 31 32 try: 32 33 server = smtplib.SMTP(EMAIL_HOST) 34 if auth_user and auth_password: 35 server.login(auth_user, auth_password) 33 36 except: 34 37 if fail_silently: … … 50 53 51 54 def mail_admins(subject, message, fail_silently=False): 52 "Sends a message to the admins, as defined by the ADMINS constant in settings.py."55 "Sends a message to the admins, as defined by the ADMINS setting." 53 56 from django.conf.settings import ADMINS, SERVER_EMAIL 54 57 send_mail(EMAIL_SUBJECT_PREFIX + subject, message, SERVER_EMAIL, [a[1] for a in ADMINS], fail_silently) 55 58 56 59 def mail_managers(subject, message, fail_silently=False): 57 "Sends a message to the managers, as defined by the MANAGERS constant in settings.py"60 "Sends a message to the managers, as defined by the MANAGERS setting." 58 61 from django.conf.settings import MANAGERS, SERVER_EMAIL 59 62 send_mail(EMAIL_SUBJECT_PREFIX + subject, message, SERVER_EMAIL, [a[1] for a in MANAGERS], fail_silently) django/trunk/docs/email.txt
r2122 r2548 27 27 ``django.core.mail.send_mail``. Here's its definition:: 28 28 29 send_mail(subject, message, from_email, recipient_list, fail_silently=False) 29 send_mail(subject, message, from_email, recipient_list, 30 fail_silently=False, auth_user=EMAIL_HOST_USER, 31 auth_password=EMAIL_HOST_PASSWORD) 30 32 31 All parameters are required except for ``fail_silently``, which is ``False`` by 32 default.33 The ``subject``, ``message``, ``from_email`` and ``recipient_list`` parameters 34 are required. 33 35 34 36 * ``subject``: A string. … … 41 43 an ``smtplib.SMTPException``. See the `smtplib docs`_ for a list of 42 44 possible exceptions, all of which are subclasses of ``SMTPException``. 45 * ``auth_user``: **New in Django development version.** The optional 46 username to use to authenticate to the SMTP server. If this isn't 47 provided, Django will use the value of the ``EMAIL_HOST_USER`` setting. 48 * ``auth_password``: **New in Django development version.** The optional 49 password to use to authenticate to the SMTP server. If this isn't 50 provided, Django will use the value of the ``EMAIL_HOST_PASSWORD`` 51 setting. 43 52 44 53 .. _smtplib docs: http://www.python.org/doc/current/lib/module-smtplib.html … … 50 59 Here's the definition:: 51 60 52 send_mass_mail(datatuple, fail_silently=False): 61 send_mass_mail(datatuple, fail_silently=False, 62 auth_user=EMAIL_HOST_USER, auth_password=EMAIL_HOST_PASSWORD): 53 63 54 64 ``datatuple`` is a tuple in which each element is in this format:: … … 56 66 (subject, message, from_email, recipient_list) 57 67 58 ``fail_silently`` has the same function as in ``send_mail()``. 68 ``fail_silently``, ``auth_user`` and ``auth_password`` have the same functions 69 as in ``send_mail()``. Note that ``auth_user`` and ``auth_password`` are only 70 available in the Django development version. 59 71 60 72 Each separate element of ``datatuple`` results in a separate e-mail message. django/trunk/docs/settings.txt
r2509 r2548 334 334 335 335 The host to use for sending e-mail. 336 337 EMAIL_HOST_PASSWORD 338 ------------------- 339 340 Default: ``''`` (Empty string) 341 342 **New in Django development version.** 343 344 Username to use for the SMTP server defined in ``EMAIL_HOST``. If empty, 345 Django won't attempt authentication. 346 347 See also ``EMAIL_HOST_USER``. 348 349 EMAIL_HOST_USER 350 --------------- 351 352 Default: ``''`` (Empty string) 353 354 **New in Django development version.** 355 356 Username to use for the SMTP server defined in ``EMAIL_HOST``. If empty, 357 Django won't attempt authentication. 358 359 See also ``EMAIL_HOST_PASSWORD``. 336 360 337 361 EMAIL_SUBJECT_PREFIX
