Example #1
0
def build_welcome_mail():
    current_path = os.path.dirname(os.path.abspath(__file__))
    with open(os.path.join(current_path, '..', 'assets', 'welcome.mail')) as mail_template_file:
        mail_template = message_from_file(mail_template_file)
    welcome_mail = InputMail()
    welcome_mail.headers['To'] = InputMail.FROM_EMAIL_ADDRESS
    welcome_mail.headers['Subject'] = mail_template['Subject']
    welcome_mail.headers['Date'] = iso_now()
    welcome_mail._mime = MIMEMultipart()
    for payload in mail_template.get_payload():
        welcome_mail._mime.attach(payload)
        if payload.get_content_type() == 'text/plain':
            welcome_mail.body = payload.as_string()
    return welcome_mail