Code

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#5615 closed (fixed)

Typo in email docs: "to" field should be a list

Reported by: raprasad@… Owned by: nobody
Component: Documentation Version: master
Severity: Keywords: email to
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

documentation typo on:

http://www.djangoproject.com/documentation/email/#sending-alternative-content-types

The "to" address is not a list:

-fix 1-

orig:

subject, from_email, to = 'hello', 'from@example.com', 'to@example.com'

new:

subject, from_email, to = 'hello', 'from@example.com', ['to@example.com']

--- OR ---

-fix 2-
orig:

msg = EmailMultiAlternatives(subject, text_content, from_email, to)

new:

msg = EmailMultiAlternatives(subject, text_content, from_email, [to])

Attachments (1)

5615.diff (605 bytes) - added by tvrg 7 years ago.

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by tvrg

comment:1 Changed 7 years ago by tvrg

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I prefer the second fix since it is consistent with the next example


msg = EmailMessage(subject, html_content, from_email, [to])
msg.content_subtype = "html" # Main content is now text/html
msg.send()


feel free to disagree

comment:2 Changed 7 years ago by mboersma

  • Keywords email to added
  • Summary changed from typo in e-mail documenation: "to" address is a string, not a list to Typo in email docs: "to" field should be a list
  • Triage Stage changed from Unreviewed to Ready for checkin

The specific code that this ends up calling is the parent class EmailMessage.init, which does indeed expect a list as it does ','.join() on it soon afterward. I prefer the second fix as you have in your patch, too.

comment:3 Changed 7 years ago by raprasad@…

Agreed.

tvrg's patch looks good

comment:4 Changed 7 years ago by ubernostrum

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

(In [6431]) Fixed #5615: Corrected a typo in docs/email.txt. Thanks, raprasad@….

comment:5 Changed 7 years ago by anonymous

cool

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.