From 5f24384a9ae847f95b4ec6d8d8d49f662779ed4b Mon Sep 17 00:00:00 2001 From: b3yond Date: Sat, 6 Oct 2018 02:46:54 +0200 Subject: [PATCH] fixing #38: putting the city into the From address of report mails --- active_bots/mailbot.py | 5 +++-- sendmail.py | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/active_bots/mailbot.py b/active_bots/mailbot.py index 8125137..c10229e 100644 --- a/active_bots/mailbot.py +++ b/active_bots/mailbot.py @@ -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) diff --git a/sendmail.py b/sendmail.py index d739d78..9772836 100755 --- a/sendmail.py +++ b/sendmail.py @@ -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))