예제 #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