fixing #38: putting the city into the From address of report mails

This commit is contained in:
b3yond 2018-10-06 02:46:54 +02:00
parent a459ba92c1
commit 5f24384a9a
2 changed files with 8 additions and 4 deletions

View file

@ -36,8 +36,9 @@ class Mailbot(Bot):
+ db.mail_subscription_token(rec, user.get_city())
if report.author != rec:
try:
sendmail.sendmail(rec, "Ticketfrei " + user.get_city() +
" Report", body=body)
city = user.get_city()
sendmail.sendmail(rec, "Ticketfrei " + city + " Report",
city=city, body=body)
except Exception:
logger.error("Sending Mail failed.", exc_info=True)

View file

@ -71,9 +71,12 @@ class Mailer(object):
return "Sent mail to " + recipient + ": " + subject
def sendmail(to, subject, body=''):
def sendmail(to, subject, city=None, body=''):
msg = MIMEMultipart()
msg['From'] = 'Ticketfrei <%s@%s>' % (getuser(), getfqdn())
if city:
msg['From'] = 'Ticketfrei <%s@%s>' % (city, getfqdn())
else:
msg['From'] = 'Ticketfrei <%s@%s>' % (getuser(), getfqdn())
msg['To'] = to
msg['Subject'] = '[Ticketfrei] %s' % (subject, )
msg.attach(MIMEText(body))