From 74709177aa18b2713132e4e8d42a362240684565 Mon Sep 17 00:00:00 2001 From: dy0gu Date: Mon, 11 Nov 2024 00:17:27 +0000 Subject: [PATCH] feat: add reply-to header --- src/pages/home.py | 9 +++++++++ src/services/email.py | 10 +++++++++- src/utils/config.py | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pages/home.py b/src/pages/home.py index e0a24ab..4215708 100644 --- a/src/pages/home.py +++ b/src/pages/home.py @@ -118,6 +118,12 @@ def __init__(self): lambda text: config.origin.set(text) ) + self.replyLabel = BodyLabel("REPLY") + self.replyInput = LineEdit() + self.replyInput.setMaximumWidth(500) + self.replyInput.setText(config.reply.get()) + self.replyInput.textChanged.connect(lambda text: config.reply.set(text)) + self.ccLabel = BodyLabel("CC") self.ccInput = LineEdit() self.ccInput.setMaximumWidth(500) @@ -132,6 +138,8 @@ def __init__(self): self.headLayout.addWidget(self.subjectInput) self.headLayout.addWidget(self.originLabel) self.headLayout.addWidget(self.originInput) + self.headLayout.addWidget(self.replyLabel) + self.headLayout.addWidget(self.replyInput) self.headLayout.addWidget(self.ccLabel) self.headLayout.addWidget(self.ccInput) self.headLayout.addWidget(self.bccLabel) @@ -320,6 +328,7 @@ def runEmailer(self): self.originInput.text() if self.originInput.text() else self.smtpUsernameInput.text(), + self.replyInput.text(), self.ccInput.text(), self.bccInput.text(), self.bodyFileInput.text(), diff --git a/src/services/email.py b/src/services/email.py index f5ea2d0..7662e21 100644 --- a/src/services/email.py +++ b/src/services/email.py @@ -25,6 +25,7 @@ def __init__( smtpPassword: str, subject: str, origin: str, + reply: str, cc: str, bcc: str, bodyPath: str, @@ -38,6 +39,7 @@ def __init__( self.smtpPassword = smtpPassword self.subject = subject self.origin = origin + self.reply = reply self.cc = cc self.bcc = bcc self.bodyPath = bodyPath @@ -184,7 +186,13 @@ def run(self): # Configure email headers message["To"] = row[cols[0]].strip() message["From"] = self.origin.strip() - message["Subject"] = Template(self.subject).substitute(row).strip() + message["Subject"] = ( + Template(self.subject).substitute(row).strip() + ) + if self.reply: + message["Reply-To"] = ( + Template(self.reply).substitute(row).strip() + ) if self.cc: message["Cc"] = Template(self.cc).substitute(row).strip() if self.bcc: diff --git a/src/utils/config.py b/src/utils/config.py index 2be0e60..1b14709 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -55,6 +55,7 @@ class Config(QConfig): smtpUsername = ConfigItem("Email", "SMTPUsername", "") smtpPassword = ConfigItem("Email", "SMTPPassword", "") origin = ConfigItem("Email", "Origin", "") + reply = ConfigItem("Email", "Reply", "") def reset(self): for _, attr in self.__class__.__dict__.items():