Django

Code

Changeset 5562

Show
Ignore:
Timestamp:
06/30/07 16:06:47 (1 year ago)
Author:
adrian
Message:

Edited docs/email.txt changes from [5548]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/email.txt

    r5561 r5562  
    301301~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    302302 
    303 It is often useful to include multiple versions of the content in an e-mail. 
    304 For instance, sending both text and HTML versions of an e-mail. You can do 
    305 this using the ``EmailMultiAlternatives`` class. This sub-class of 
    306 ``EmailMessage`` has an ``attach_alternative()`` method for including 
    307 extra versions of the message body in the e-mail. All the other methods 
    308 (including the class initialization) are inherited directly from 
     303It can be useful to include multiple versions of the content in an e-mail; 
     304the classic example is to send both text and HTML versions of a message. With 
     305Django's e-mail library, you can do this using the ``EmailMultiAlternatives`` 
     306class. This subclass of ``EmailMessage`` has an ``attach_alternative()`` method 
     307for including extra versions of the message body in the e-mail. All the other 
     308methods (including the class initialization) are inherited directly from 
    309309``EmailMessage``. 
    310310 
     
    313313    from django.core.mail import EmailMultiAlternatives 
    314314 
    315     subject, from_email, to = ... 
    316     text_content = "This is an important message." 
    317     html_content = "<p>This is an <strong>important</strong> message." 
     315    subject, from_email, to = 'hello', 'from@example.com', 'to@example.com' 
     316    text_content = 'This is an important message.' 
     317    html_content = '<p>This is an <strong>important</strong> message.' 
    318318    msg = EmailMultiAlternatives(subject, text_content, from_email, to) 
    319319    msg.attach_alternative(html_content, "text/html") 
     
    321321 
    322322By default, the MIME type of the ``body`` parameter in an ``EmailMessage`` is 
    323 ``"text/plain"``. It is good practice to leave this alone, since it guarantees 
    324 that any recipient will be able to read the e-mail, regardless of their mail 
    325 client. However, if you are confident that your recipients can handle an 
    326 alternative content type, you can use the ``content_subtype`` attribute on the 
    327 ``EmailMessage`` class to change the main content type. The major type will 
    328 always be ``"text"``, but you can change to the subtype. For example:: 
     323``"text/plain"``. It is good practice to leave this alone, because it 
     324guarantees that any recipient will be able to read the e-mail, regardless of 
     325their mail client. However, if you are confident that your recipients can 
     326handle an alternative content type, you can use the ``content_subtype`` 
     327attribute on the ``EmailMessage`` class to change the main content type. The 
     328major type will always be ``"text"``, but you can change it to the subtype. For 
     329example:: 
    329330 
    330331    msg = EmailMessage(subject, html_content, from_email, to)