Skip to content

Commit 64adc41

Browse files
Edited docs/email.txt changes from [5141] and other recent changesets
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5155 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 1889db4 commit 64adc41

File tree

1 file changed

+42
-36
lines changed

1 file changed

+42
-36
lines changed

docs/email.txt

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ In two lines::
2020
send_mail('Subject here', 'Here is the message.', 'from@example.com',
2121
['to@example.com'], fail_silently=False)
2222

23-
Mail will be sent using the SMTP host and port specified in the `EMAIL_HOST`_
24-
and `EMAIL_PORT`_ settings. The `EMAIL_HOST_USER`_ and `EMAIL_HOST_PASSWORD`_
25-
settings, if set, will be used to authenticate to the SMTP server and the
26-
`EMAIL_USE_TLS`_ settings will control whether a secure connection is used.
23+
Mail is sent using the SMTP host and port specified in the `EMAIL_HOST`_ and
24+
`EMAIL_PORT`_ settings. The `EMAIL_HOST_USER`_ and `EMAIL_HOST_PASSWORD`_
25+
settings, if set, are used to authenticate to the SMTP server, and the
26+
`EMAIL_USE_TLS`_ setting controls whether a secure connection is used.
2727

2828
.. note::
2929

30-
The character set of email sent with ``django.core.mail`` will be set to
30+
The character set of e-mail sent with ``django.core.mail`` will be set to
3131
the value of your `DEFAULT_CHARSET setting`_.
3232

3333
.. _DEFAULT_CHARSET setting: ../settings/#default-charset
@@ -37,7 +37,6 @@ settings, if set, will be used to authenticate to the SMTP server and the
3737
.. _EMAIL_HOST_PASSWORD: ../settings/#email-host-password
3838
.. _EMAIL_USE_TLS: ../settings/#email-use-tls
3939

40-
4140
send_mail()
4241
===========
4342

@@ -193,57 +192,64 @@ The EmailMessage and SMTPConnection classes
193192

194193
Django's ``send_mail()`` and ``send_mass_mail()`` functions are actually thin
195194
wrappers that make use of the ``EmailMessage`` and ``SMTPConnection`` classes
196-
in ``django.mail``. If you ever need to customize the way Django sends email,
197-
you can subclass these two classes to suit your needs.
195+
in ``django.core.mail``. If you ever need to customize the way Django sends
196+
e-mail, you can subclass these two classes to suit your needs.
198197

199198
.. note::
200199
Not all features of the ``EmailMessage`` class are available through the
201200
``send_mail()`` and related wrapper functions. If you wish to use advanced
202-
features such as including BCC recipients or multi-part email, you will
203-
need to create ``EmailMessage`` instances directly.
201+
features, such as BCC'ed recipients or multi-part e-mail, you'll need to
202+
create ``EmailMessage`` instances directly.
204203

205-
In general, ``EmailMessage`` is responsible for creating the email message
204+
In general, ``EmailMessage`` is responsible for creating the e-mail message
206205
itself. ``SMTPConnection`` is responsible for the network connection side of
207206
the operation. This means you can reuse the same connection (an
208207
``SMTPConnection`` instance) for multiple messages.
209208

210-
The ``EmailMessage`` class is initialised as follows::
209+
The ``EmailMessage`` class is initialized as follows::
211210

212211
email = EmailMessage(subject, body, from_email, to, bcc, connection)
213212

214213
All of these parameters are optional. If ``from_email`` is omitted, the value
215214
from ``settings.DEFAULT_FROM_EMAIL`` is used. Both the ``to`` and ``bcc``
216-
parameters are lists of addresses.
217-
218-
The class has the following methods that you can use:
219-
220-
* ``send()`` sends the message, using either the connection that is specified
221-
in the ``connection`` attribute, or creating a new connection if none already
222-
exists.
223-
* ``message()`` constructs a ``django.core.mail.SafeMIMEText`` object (a
224-
sub-class of Python's ``email.MIMEText.MIMEText`` class) holding the
225-
message to be sent. If you ever need to extend the `EmailMessage` class,
226-
you will probably want to override this method to put the content you wish
227-
into the MIME object.
228-
* ``recipients()`` returns a lists of all the recipients of the message,
229-
whether they are recorded in the ``to`` or ``bcc`` attributes. This is
230-
another method you need to possibly override when sub-classing, since the
231-
SMTP server needs to be told the full list of recipients when the message
232-
is sent. If you add another way to specify recipients in your class, they
233-
need to be returned from this method as well.
215+
parameters are lists of addresses, as strings.
216+
217+
For example::
218+
219+
email = EmailMessage('Hello', 'Body goes here', 'from@example.com',
220+
['to1@example.com', 'to2@example.com'],
221+
['bcc@example.com'])
222+
223+
The class has the following methods:
224+
225+
* ``send()`` sends the message, using either the connection that is
226+
specified in the ``connection`` attribute, or creating a new connection
227+
if none already exists.
228+
229+
* ``message()`` constructs a ``django.core.mail.SafeMIMEText`` object (a
230+
sub-class of Python's ``email.MIMEText.MIMEText`` class) holding the
231+
message to be sent. If you ever need to extend the `EmailMessage` class,
232+
you'll probably want to override this method to put the content you wish
233+
into the MIME object.
234+
235+
* ``recipients()`` returns a list of all the recipients of the message,
236+
whether they're recorded in the ``to`` or ``bcc`` attributes. This is
237+
another method you might need to override when sub-classing, because the
238+
SMTP server needs to be told the full list of recipients when the message
239+
is sent. If you add another way to specify recipients in your class, they
240+
need to be returned from this method as well.
234241

235242
The ``SMTPConnection`` class is initialized with the host, port, username and
236243
password for the SMTP server. If you don't specify one or more of those
237244
options, they are read from your settings file.
238245

239-
If you are sending lots of messages at once, the ``send_messages()`` method of
240-
the ``SMTPConnection`` class will be useful. It takes a list of ``EmailMessage``
241-
instances (or sub-classes) and sends them over a single connection. For
242-
example, if you have a function called ``get_notification_email()`` that returns a
243-
list of ``EmailMessage`` objects representing some periodic email you wish to
246+
If you're sending lots of messages at once, the ``send_messages()`` method of
247+
the ``SMTPConnection`` class is useful. It takes a list of ``EmailMessage``
248+
instances (or subclasses) and sends them over a single connection. For example,
249+
if you have a function called ``get_notification_email()`` that returns a
250+
list of ``EmailMessage`` objects representing some periodic e-mail you wish to
244251
send out, you could send this with::
245252

246253
connection = SMTPConnection() # Use default settings for connection
247254
messages = get_notification_email()
248255
connection.send_messages(messages)
249-

0 commit comments

Comments
 (0)