o a @sdZddlmZddlmZmZmZmZmZm Z m Z m Z ddl m Z mZddlmZgdZdd d Z  dd d Z  dd dZ  dddZ  dddZdS)z Tools for sending email. )settings)DEFAULT_ATTACHMENT_MIME_TYPEBadHeaderError EmailMessageEmailMultiAlternativesSafeMIMEMultipart SafeMIMETextforbid_multi_line_headers make_msgid)DNS_NAME CachedDnsName) import_string)r r rrrrrr rr get_connection send_mailsend_mass_mail mail_admins mail_managersNFcKs t|ptj}|dd|i|S)zLoad an email backend and return an instance of it. If backend is None (default), use settings.EMAIL_BACKEND. Both fail_silently and other keyword arguments are used in the constructor of the backend. fail_silentlyN)r r EMAIL_BACKEND)backendrkwdsklassrr;/usr/lib/python3/dist-packages/django/core/mail/__init__.pyrsrc Cs<|pt|||d}t|||||d} |r| |d| S)a Easy wrapper for sending a single message to a recipient list. All members of the recipient list will see the other recipients in the 'To' field. If from_email is None, use the DEFAULT_FROM_EMAIL setting. If auth_user is None, use the EMAIL_HOST_USER setting. If auth_password is None, use the EMAIL_HOST_PASSWORD setting. Note: The API for this method is frozen. New code wanting to extend the functionality should use the EmailMessage class directly. usernamepasswordr connection text/html)rrattach_alternativesend) subjectmessage from_emailrecipient_listr auth_user auth_passwordr html_messagemailrrrr&s rcs.pt|||dfdd|D}|S)a' Given a datatuple of (subject, message, from_email, recipient_list), send each message to each recipient list. Return the number of emails sent. If from_email is None, use the DEFAULT_FROM_EMAIL setting. If auth_user and auth_password are set, use them to log in. If auth_user is None, use the EMAIL_HOST_USER setting. If auth_password is None, use the EMAIL_HOST_PASSWORD setting. Note: The API for this method is frozen. New code wanting to extend the functionality should use the EmailMessage class directly. rc s&g|]\}}}}t||||dqS)r)r).0r"r#sender recipientrrr Ss z"send_mass_mail..)r send_messages) datatuplerr&r'rmessagesrrrr@s  rcCptjsdStddtjDstdtdtj|f|tjddtjD|d}|r0||d |j|d dS) z?Send a message to the admins, as defined by the ADMINS setting.Ncs*|]}t|ttfot|dkVqdSN isinstancelisttuplelenr*arrr _(zmail_admins..z.The ADMINS setting must be a list of 2-tuples.%s%scSg|]}|dqSrr:rrrr-czmail_admins..rrr) rADMINSall ValueErrorrEMAIL_SUBJECT_PREFIX SERVER_EMAILr r!r"r#rrr(r)rrrrZ rcCr1) zCSend a message to the managers, as defined by the MANAGERS setting.Ncsr2r3r5r:rrrr<pr=z mail_managers..z0The MANAGERS setting must be a list of 2-tuples.r>cSr?r@rr:rrrr-trBz!mail_managers..rrrC) rMANAGERSrErFrrGrHr r!rIrrrrkrJr)NF)FNNNN)FNNN)FNN)__doc__ django.confrdjango.core.mail.messagerrrrrrr r django.core.mail.utilsr r django.utils.module_loadingr __all__rrrrrrrrrs& (