email: Add more debugging when sending emails

We're currently spamming an uploader, and it's hard to figure out why.
Let's output why we are deciding to do so.
This commit is contained in:
Iain Lane 2019-08-12 15:27:58 +01:00
parent e51cc58a2b
commit 879e7e1088
No known key found for this signature in database
GPG Key ID: E352D5C51C5041D4

@ -232,8 +232,9 @@ class EmailPolicy(BasePolicy, Rest):
recipients = ', '.join(emails)
msg = MESSAGE.format(**locals())
try:
self.log("%s/%s stuck for %d days, emailing %s" %
(source_name, version, age, recipients))
self.log("%s/%s stuck for %d days (email last sent at %d days old, "
"threshold for sending %d days), emailing %s" %
(source_name, version, age, last_sent, last_due, recipients))
server = smtplib.SMTP(self.email_host)
server.sendmail('noreply@canonical.com', emails, msg)
server.quit()