mail.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:ac-mediator 作者: AudioCommons 项目源码 文件源码
def send_mail(to_emails, from_email=settings.DEFAULT_FROM_EMAIL, subject='No subject',
              message=None, template=None, context=None, fail_silently=True):
    """Send email using Django's send_email function but setting a number of defaults and adding a
    prefix in the subject. It also renders a template with a context if provided."""
    if not subject.startswith(settings.EMAIL_SUBJECT_PREFIX):
        subject = settings.EMAIL_SUBJECT_PREFIX + subject
    if template is not None and context is not None:
        message = render_to_string(template, context)
    if type(to_emails) is not list and type(to_emails) is not tuple:
        to_emails = (to_emails, )
    django_send_email(subject, message, from_email, to_emails, fail_silently)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号