Initialize a single email message (which can be sent to multiple recipients).
(
self,
subject="",
body="",
from_email=None,
to=None,
*,
bcc=None,
connection=None,
attachments=None,
headers=None,
cc=None,
reply_to=None,
)
| 258 | ], |
| 259 | ) |
| 260 | def __init__( |
| 261 | self, |
| 262 | subject="", |
| 263 | body="", |
| 264 | from_email=None, |
| 265 | to=None, |
| 266 | *, |
| 267 | bcc=None, |
| 268 | connection=None, |
| 269 | attachments=None, |
| 270 | headers=None, |
| 271 | cc=None, |
| 272 | reply_to=None, |
| 273 | ): |
| 274 | """ |
| 275 | Initialize a single email message (which can be sent to multiple |
| 276 | recipients). |
| 277 | """ |
| 278 | if to: |
| 279 | if isinstance(to, str): |
| 280 | raise TypeError('"to" argument must be a list or tuple') |
| 281 | self.to = list(to) |
| 282 | else: |
| 283 | self.to = [] |
| 284 | if cc: |
| 285 | if isinstance(cc, str): |
| 286 | raise TypeError('"cc" argument must be a list or tuple') |
| 287 | self.cc = list(cc) |
| 288 | else: |
| 289 | self.cc = [] |
| 290 | if bcc: |
| 291 | if isinstance(bcc, str): |
| 292 | raise TypeError('"bcc" argument must be a list or tuple') |
| 293 | self.bcc = list(bcc) |
| 294 | else: |
| 295 | self.bcc = [] |
| 296 | if reply_to: |
| 297 | if isinstance(reply_to, str): |
| 298 | raise TypeError('"reply_to" argument must be a list or tuple') |
| 299 | self.reply_to = list(reply_to) |
| 300 | else: |
| 301 | self.reply_to = [] |
| 302 | self.from_email = from_email or settings.DEFAULT_FROM_EMAIL |
| 303 | self.subject = subject |
| 304 | self.body = body or "" |
| 305 | self.attachments = [] |
| 306 | if attachments: |
| 307 | for attachment in attachments: |
| 308 | if isinstance(attachment, email.message.MIMEPart): |
| 309 | self.attach(attachment) |
| 310 | elif isinstance(attachment, MIMEBase): |
| 311 | # RemovedInDjango70Warning. |
| 312 | self.attach(attachment) |
| 313 | else: |
| 314 | self.attach(*attachment) |
| 315 | self.extra_headers = headers or {} |
| 316 | # RemovedInDjango70Warning. |
| 317 | if connection is not None: |
nothing calls this directly
no test coverage detected