From b9a8679e7f0a91c5f1803465b16d4e152c38fb5f Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Sat, 23 Feb 2013 20:42:11 +0100 Subject: fix outsources mail code --- invoice/mailhelper.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'invoice/mailhelper.py') diff --git a/invoice/mailhelper.py b/invoice/mailhelper.py index 49721cc..3beb4c7 100644 --- a/invoice/mailhelper.py +++ b/invoice/mailhelper.py @@ -1,7 +1,11 @@ #!/usr/bin/env python3 #-*- coding: utf-8 -*- +from email.mime.multipart import MIMEMultipart +from email.mime.application import MIMEApplication +from email.mime.text import MIMEText +from email.header import Header -import time +import time, email.utils, smtplib class MAIL(object): def __init__(self, server, port, username, password): @@ -35,6 +39,10 @@ class MAIL(object): pdf = MIMEApplication(data, 'pdf') pdf.add_header('Content-Disposition', 'attachment', filename = name) msg.attach(pdf) + if name.endswith("db"): + file = MIMEApplication(data) + file.add_header('Content-Disposition', 'attachment', filename = name) + msg.attach(file) else: txt = MIMEText(data, 'plain', 'utf-8') txt.add_header('Content-Disposition', 'attachment', filename = name) -- cgit v1.2.3