Skip to content

Commit

Permalink
feat: add reply-to header
Browse files Browse the repository at this point in the history
  • Loading branch information
dy0gu committed Nov 11, 2024
1 parent 1730c1e commit 7470917
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ def __init__(self):
lambda text: config.origin.set(text)
)

self.replyLabel = BodyLabel("<b>REPLY</b>")
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("<b>CC</b>")
self.ccInput = LineEdit()
self.ccInput.setMaximumWidth(500)
Expand All @@ -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)
Expand Down Expand Up @@ -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(),
Expand Down
10 changes: 9 additions & 1 deletion src/services/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(
smtpPassword: str,
subject: str,
origin: str,
reply: str,
cc: str,
bcc: str,
bodyPath: str,
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 7470917

Please sign in to comment.