Python django.conf.settings.EMAIL_FROM Examples

The following are 11 code examples of django.conf.settings.EMAIL_FROM(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .
Example #1
Source File: tasks.py    From ecommerce_website_development with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def send_register_active_email(to_email, username, token):
    """发送激活邮件"""
    # 组织邮件内容
    subject = '天天生鲜欢迎信息'
    message = ''
    sender = settings.EMAIL_FROM
    receiver = [to_email]
    html_message = """
                        <h1>%s, 欢迎您成为天天生鲜注册会员</h1>
                        请点击以下链接激活您的账户(7个小时内有效)<br/>
                        <a href="http://127.0.0.1:8000/user/active/%s">http://127.0.0.1:8000/user/active/%s</a>
                    """ % (username, token, token)

    # 发送激活邮件
    # send_mail(subject=邮件标题, message=邮件正文,from_email=发件人, recipient_list=收件人列表)
    send_mail(subject, message, sender, receiver, html_message=html_message) 
Example #2
Source File: tasks.py    From ecommerce_website_development with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def send_register_active_email(to_email, username, token):
    """发送激活邮件"""
    # 组织邮件内容
    subject = '天天生鲜欢迎信息'
    message = ''
    sender = settings.EMAIL_FROM
    receiver = [to_email]
    html_message = """
                            <h1>%s, 欢迎您成为天天生鲜注册会员</h1>
                            请点击以下链接激活您的账户<br/>
                            <a href="http://127.0.0.1:8000/user/active/%s">http://127.0.0.1:8000/user/active/%s</a>
                        """ % (username, token, token)

    # 发送激活邮件
    # send_mail(subject=邮件标题, message=邮件正文,from_email=发件人, recipient_list=收件人列表)
    send_mail(subject, message, sender, receiver, html_message=html_message) 
Example #3
Source File: helpers.py    From FIR with GNU General Public License v3.0 5 votes vote down vote up
def prepare_email_message(to, subject, body, behalf=None, cc=None, bcc=None, request=None):
    reply_to = {}

    if hasattr(settings, 'REPLY_TO'):
        reply_to = {'Reply-To': settings.REPLY_TO, 'Return-Path': settings.REPLY_TO}

    if behalf is None and hasattr(settings, 'EMAIL_FROM'):
        behalf = settings.EMAIL_FROM

    if not isinstance(to, (tuple, list)):
        to = to.split(';')

    email_message = EmailMultiAlternatives(
        subject=subject,
        body=body,
        from_email=behalf,
        to=to,
        cc=cc,
        bcc=bcc,
        headers=reply_to
    )
    email_message.attach_alternative(markdown2.markdown(
        body,
        extras=["link-patterns", "tables", "code-friendly"],
        link_patterns=registry.link_patterns(request),
        safe_mode=True
    ),
        'text/html')

    return email_message 
Example #4
Source File: email.py    From FIR with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        super(EmailMethod, self).__init__()
        if hasattr(settings, 'EMAIL_FROM') and settings.EMAIL_FROM is not None:
            self.server_configured = True 
Example #5
Source File: send_email.py    From Django-blog with MIT License 5 votes vote down vote up
def send_email(email, send_type='register'):
    """
        发送邮件的方法
        register:   注册账号
        forget:     找回密码
        change:     修改邮箱
    """
    if send_type == 'register':
        subject = '彬彬博客注册激活链接'
        code_str = generate_random_str(16)
        message = '请点击下面的链接激活您的账号: http://127.0.0.1:8000/active/{0}'.format(code_str)

    elif send_type == 'forget':
        subject = '彬彬博客忘记密码连接'
        code_str = generate_random_str(8)
        timestamp = int(time.time())
        md5 = hashlib.md5()
        md5_str = md5.update((code_str + email + str(timestamp)).encode('utf8'))
        hash_str = md5.hexdigest()
        message = '请点击下面的链接修改你的密码: http://127.0.0.1:8000/reset?timestamp={0}&hash={1}&email={2}'.format(timestamp,
                                                                                                        hash_str, email)
    elif send_type == 'change':
        subject = '彬彬博客修改邮箱连接'
        code_str = generate_random_str(6)
        message = '你的邮箱验证码为: {0}'.format(code_str)
    else:
        return False

    status = send_mail(subject, message, settings.EMAIL_FROM, [email])
    if status:  # 发送成功
        email_code = EmailVerifyCode()
        email_code.email = email
        email_code.code = code_str
        email_code.type = send_type
        email_code.save()
        return True
    else:
        return False 
Example #6
Source File: tasks.py    From Django-blog with MIT License 5 votes vote down vote up
def send_email_task(email, code_str, send_type):
    """
    使用celery异步发送邮件
    @email 邮件收件方
    @code_str 邮件验证码
    @send_type: 邮件类型
    """
    if send_type == 'register':
        subject = '彬彬博客注册激活链接'
        message = '请点击下面的链接激活您的账号: http://127.0.0.1:8000/active/{0}'.format(code_str)

    elif send_type == 'forget':
        subject = '彬彬博客忘记密码连接'
        timestamp = int(time.time())
        md5 = hashlib.md5()
        md5_str = md5.update((code_str + email + str(timestamp)).encode('utf8'))
        hash_str = md5.hexdigest()
        message = '请点击下面的链接修改你的密码: http://127.0.0.1:8000/reset?timestamp={0}&hash={1}&email={2}'.format(timestamp,
                                                                                                        hash_str, email)
    elif send_type == 'change':
        subject = '彬彬博客修改邮箱连接'
        message = '你的邮箱验证码为: {0}'.format(code_str)
    else:
        logger.error('非法的发送类型'.format(email))
        return {'status': 'fail', 'error': 'illegal send_type'}

    status = send_mail(subject, message, settings.EMAIL_FROM, [email])  # ,html_message=

    if status:
        logger.info('{0}邮件发送成功'.format(email))
        return {'status': 'success', 'email': email}
    else:
        logger.error('{0}邮件发送失败'.format(email))
        return {'status': 'fail', 'email': email} 
Example #7
Source File: tasks.py    From CTF_AWD_Platform with MIT License 5 votes vote down vote up
def SendMail(code,recipient_list):

    message = '【SDUTCTF】 欢迎注册SDUTCTF平台,您的验证码为:{} ,验证码有效时间为五分钟。'.format(code)
    status = send_mail('注册SDUTCTF', '', settings.EMAIL_FROM, recipient_list, html_message=message)
    return status 
Example #8
Source File: Email.py    From CTF_AWD_Platform with MIT License 5 votes vote down vote up
def SendMail(code,recipient_list):

    message = '【SDUTCTF】 欢迎注册SDUTCTF平台,您的验证码为:{} ,验证码有效时间为五分钟。'.format(code)
    status = send_mail('注册SDUTCTF', '', settings.EMAIL_FROM, recipient_list, html_message=message)
    return status


# send_list = ['755563428@qq.com']
# SendMail(send_list) 
Example #9
Source File: notifications.py    From sfm-ui with MIT License 5 votes vote down vote up
def _create_space_email(email_address, msg_cache):
    text_template = get_template('email/free_space_email.txt')
    html_template = get_template('email/free_space_email.html')
    msg_cache["url"] = _create_url(reverse('home'))
    d = msg_cache
    msg = EmailMultiAlternatives("[WARNING] Low free space on SFM server",
                                 text_template.render(d), settings.EMAIL_FROM, [email_address])
    msg.attach_alternative(html_template.render(d), "text/html")
    return msg 
Example #10
Source File: notifications.py    From sfm-ui with MIT License 5 votes vote down vote up
def _create_queue_warn_email(email_address, msg_cache):
    text_template = get_template('email/queue_length_email.txt')
    html_template = get_template('email/queue_length_email.html')
    msg_cache["url"] = _create_url(reverse('home'))
    msg_cache["monitor_url"] = _create_url(reverse('monitor'))
    d = msg_cache
    msg = EmailMultiAlternatives("[WARNING] Long message queue on SFM server",
                                 text_template.render(d), settings.EMAIL_FROM, [email_address])
    msg.attach_alternative(html_template.render(d), "text/html")
    return msg 
Example #11
Source File: notifications.py    From sfm-ui with MIT License 5 votes vote down vote up
def _create_email(user, collection_set_cache):
    text_template = get_template('email/user_harvest_email.txt')
    html_template = get_template('email/user_harvest_email.html')
    d = _create_context(user, collection_set_cache)
    msg = EmailMultiAlternatives("Update on your Social Feed Manager harvests", text_template.render(d),
                                 settings.EMAIL_FROM, [user.email])
    msg.attach_alternative(html_template.render(d), "text/html")
    return msg