mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-10 00:42:06 +00:00
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:
@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user