mirror of
https://gitlab.com/kernel-firmware/linux-firmware.git
synced 2025-12-10 07:44:48 +01:00
Make email replies more resilient
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
This commit is contained in:
parent
8228c2222f
commit
bfd5f0b9d5
1 changed files with 22 additions and 6 deletions
|
|
@ -81,6 +81,11 @@ def quiet_cmd(cmd):
|
||||||
|
|
||||||
|
|
||||||
def reply_email(content, branch):
|
def reply_email(content, branch):
|
||||||
|
user = None
|
||||||
|
password = None
|
||||||
|
server = None
|
||||||
|
port = None
|
||||||
|
|
||||||
if "SMTP_USER" in os.environ:
|
if "SMTP_USER" in os.environ:
|
||||||
user = os.environ["SMTP_USER"]
|
user = os.environ["SMTP_USER"]
|
||||||
if "SMTP_PASS" in os.environ:
|
if "SMTP_PASS" in os.environ:
|
||||||
|
|
@ -96,15 +101,26 @@ def reply_email(content, branch):
|
||||||
reply = email.message.EmailMessage()
|
reply = email.message.EmailMessage()
|
||||||
|
|
||||||
orig = email.message_from_string(content)
|
orig = email.message_from_string(content)
|
||||||
reply["To"] = ", ".join(
|
try:
|
||||||
email.utils.formataddr(t)
|
reply["To"] = ", ".join(
|
||||||
for t in email.utils.getaddresses(
|
email.utils.formataddr(t)
|
||||||
orig.get_all("from", []) + orig.get_all("to", []) + orig.get_all("cc", [])
|
for t in email.utils.getaddresses(
|
||||||
|
orig.get_all("from", [])
|
||||||
|
+ orig.get_all("to", [])
|
||||||
|
+ orig.get_all("cc", [])
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except ValueError:
|
||||||
|
logging.warning("Failed to parse email addresses, not sending email")
|
||||||
|
return
|
||||||
|
|
||||||
reply["From"] = "linux-firmware@kernel.org"
|
reply["From"] = "linux-firmware@kernel.org"
|
||||||
reply["Subject"] = "Re: {}".format(orig["Subject"])
|
try:
|
||||||
|
reply["Subject"] = "Re: {}".format(orig["Subject"])
|
||||||
|
except ValueError:
|
||||||
|
logging.warning("Failed to parse subject, not sending email")
|
||||||
|
return
|
||||||
|
|
||||||
reply["In-Reply-To"] = orig["Message-Id"]
|
reply["In-Reply-To"] = orig["Message-Id"]
|
||||||
reply["References"] = orig["Message-Id"]
|
reply["References"] = orig["Message-Id"]
|
||||||
reply["Thread-Topic"] = orig["Thread-Topic"]
|
reply["Thread-Topic"] = orig["Thread-Topic"]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue