Пример #1
0
def send_email(subject, from_addr, to_addrs, html):
    if settings.INST_TYPE == 'dev':
        to_addrs = list(settings.DEBUG_EMAILS)
    message = MailMessage(subject=subject,
                          from_addr=from_addr,
                          to_addrs=to_addrs,
                          content=html,
                          content_type='text/html')
    client = SMTPClient(host=settings.EMAIL_HOST,
                        port=settings.EMAIL_PORT,
                        username=settings.EMAIL_HOST_USER,
                        password=settings.EMAIL_HOST_PASSWORD,
                        use_tls=settings.EMAIL_USE_TLS)
    client.send(message)
Пример #2
0
def send_email(subject, from_addr, to_addrs, html):
    if settings.INST_TYPE == 'dev':
        to_addrs = list(settings.DEBUG_EMAILS)
    message = MailMessage(
        subject=subject,
        from_addr=from_addr,
        to_addrs=to_addrs,
        content=html,
        content_type='text/html'
    )
    client = SMTPClient(
        host=settings.EMAIL_HOST,
        port=settings.EMAIL_PORT,
        username=settings.EMAIL_HOST_USER,
        password=settings.EMAIL_HOST_PASSWORD,
        use_tls=settings.EMAIL_USE_TLS
    )
    client.send(message)
Пример #3
0
def send_mail(email):
    try:
        content = file("email.html", "r")
        mail = MailMessage(
            subject='Welcome to wheezy',
            content=transform(content.read()),
            content_type='text/html',
            charset='utf-8',
            from_addr='*****@*****.**',
            to_addrs=[email])

        client = SMTPClient(
            host=host,
            port=port,
            use_tls=use_tls,
            username=username,
            password=password)
        client.send(mail)
        return True
    except:
        return False