|
16 | 16 | # under the License. |
17 | 17 |
|
18 | 18 | from datetime import date |
| 19 | +import email.utils |
19 | 20 | from pathlib import Path |
20 | 21 | import time |
21 | 22 | import sys |
@@ -382,11 +383,14 @@ def report(obj, job_name, sender_name, sender_email, recipient_email, |
382 | 383 | queue.fetch() |
383 | 384 |
|
384 | 385 | job = queue.get(job_name) |
| 386 | + report = Report(job) |
385 | 387 | email_report = EmailReport( |
386 | | - report=Report(job), |
387 | | - sender_name=sender_name, |
| 388 | + date=email.utils.formatdate(), |
| 389 | + message_id=email.utils.make_msgid(), |
| 390 | + recipient_email=recipient_email, |
| 391 | + report=report, |
388 | 392 | sender_email=sender_email, |
389 | | - recipient_email=recipient_email |
| 393 | + sender_name=sender_name, |
390 | 394 | ) |
391 | 395 |
|
392 | 396 | if poll: |
@@ -645,15 +649,18 @@ def __init__(self, token_expiration_date, days_left): |
645 | 649 | self.token_expiration_date = token_expiration_date |
646 | 650 | self.days_left = days_left |
647 | 651 |
|
| 652 | + report = TokenExpirationReport( |
| 653 | + token_expiration_date or "ALREADY_EXPIRED", days_left) |
648 | 654 | email_report = EmailReport( |
649 | | - report=TokenExpirationReport( |
650 | | - token_expiration_date or "ALREADY_EXPIRED", days_left), |
651 | | - sender_name=sender_name, |
| 655 | + date=email.utils.formatdate(), |
| 656 | + message_id=email.utils.make_msgid(), |
| 657 | + recipient_email=recipient_email, |
| 658 | + report=report, |
652 | 659 | sender_email=sender_email, |
653 | | - recipient_email=recipient_email |
| 660 | + sender_name=sender_name, |
654 | 661 | ) |
655 | 662 |
|
656 | | - message = email_report.render("token_expiration").strip() |
| 663 | + message = email_report.render("token_expiration") |
657 | 664 | if send: |
658 | 665 | ReportUtils.send_email( |
659 | 666 | smtp_user=smtp_user, |
|
0 commit comments