improve sendmail function.
This commit is contained in:
parent
10fb150c21
commit
78331212e6
12
frontend.py
12
frontend.py
|
@ -10,6 +10,10 @@ from session import SessionPlugin
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
|
|
||||||
|
|
||||||
|
def url(route):
|
||||||
|
'%s://%s/%s' % (request.urlparts.scheme, request.urlparts.netloc, route)
|
||||||
|
|
||||||
|
|
||||||
@get('/')
|
@get('/')
|
||||||
@view('template/propaganda.tpl')
|
@view('template/propaganda.tpl')
|
||||||
def propaganda():
|
def propaganda():
|
||||||
|
@ -30,11 +34,9 @@ def register_post():
|
||||||
try:
|
try:
|
||||||
sendmail(
|
sendmail(
|
||||||
email,
|
email,
|
||||||
"[Ticketfrei] Confirm your account",
|
"Confirm your account",
|
||||||
"Complete your registration here: %s://%s/confirm/%s" % (
|
"Complete your registration here: %s" % (
|
||||||
request.urlparts.scheme,
|
url('confirm/%s' % db.user_token(email, password))
|
||||||
request.urlparts.netloc,
|
|
||||||
db.user_token(email, password)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return dict(info='Confirmation mail sent.')
|
return dict(info='Confirmation mail sent.')
|
||||||
|
|
|
@ -9,8 +9,10 @@ import smtplib
|
||||||
from socket import getfqdn
|
from socket import getfqdn
|
||||||
import ssl
|
import ssl
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Mailer(object):
|
class Mailer(object):
|
||||||
"""
|
"""
|
||||||
Maintains the connection to the mailserver and sends text to users.
|
Maintains the connection to the mailserver and sends text to users.
|
||||||
|
@ -71,9 +73,9 @@ class Mailer(object):
|
||||||
|
|
||||||
def sendmail(to, subject, body=''):
|
def sendmail(to, subject, body=''):
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
msg['From'] = '%s@%s' % (getuser(), getfqdn())
|
msg['From'] = 'Ticketfrei <%s@%s>' % (getuser(), getfqdn())
|
||||||
msg['To'] = to
|
msg['To'] = to
|
||||||
msg['Subject'] = subject
|
msg['Subject'] = '[Ticketfrei] %s' % (subject, )
|
||||||
msg.attach(MIMEText(body))
|
msg.attach(MIMEText(body))
|
||||||
|
|
||||||
with smtplib.SMTP('localhost') as smtp:
|
with smtplib.SMTP('localhost') as smtp:
|
||||||
|
|
Loading…
Reference in a new issue