Factor out the sending of a templated mail to a function, we're sure

to want to use this in the future.
This commit is contained in:
Magnus Hagander
2010-01-12 19:50:50 +01:00
parent cad9eddd92
commit 6c498a47a3
2 changed files with 21 additions and 10 deletions

View File

@ -1,4 +1,7 @@
from subprocess import Popen, PIPE
from email.mime.text import MIMEText
from pgweb.util.helpers import template_to_string
def prettySize(size):
if size < 1024:
@ -15,3 +18,12 @@ def sendmail(msg):
pipe.write(msg.as_string())
pipe.close()
def send_template_mail(sender, receiver, subject, templatename, templateattr={}):
msg = MIMEText(
template_to_string(templatename, templateattr),
_charset='utf-8')
msg['Subject'] = subject
msg['To'] = receiver
msg['From'] = sender
sendmail(msg)