Skip to content

Commit

Permalink
Reply-to user email on tool error email
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit authored and cat-bro committed Mar 27, 2024
1 parent db39aed commit d33c534
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
8 changes: 8 additions & 0 deletions lib/galaxy/config/schemas/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,14 @@ mapping:
set. Also this email is shown as a contact to user in case of Galaxy
misconfiguration and other events user may encounter.
error_email_reply_to_user:
type: bool
required: false
desc: |
When sending email reports for tool errors, include the user's email address
in the Reply-to SMTP header (used by some ticketing systems to identify the
appropriate response address).
email_from:
type: str
required: false
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/tools/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def _send_report(self, user, email=None, message=None, **kwd):
except Exception:
pass

reply_to = user.email if self.app.config.error_email_reply_to_user else None
return util.send_mail(
self.app.config.email_from, to, subject, self.report, self.app.config, html=self.html_report
self.app.config.email_from, to, subject, self.report, self.app.config, html=self.html_report, reply_to=reply_to
)
10 changes: 8 additions & 2 deletions lib/galaxy/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ def size_to_bytes(size):
raise ValueError(f"Unknown multiplier '{multiple}' in '{size}'")


def send_mail(frm, to, subject, body, config, html=None):
def send_mail(frm, to, subject, body, config, html=None, reply_to=None):
"""
Sends an email.
Expand All @@ -1527,7 +1527,10 @@ def send_mail(frm, to, subject, body, config, html=None):
:type html: str
:param html: Alternative HTML representation of the body content. If
provided will convert the message to a MIMEMultipart. (Default 'None')
provided will convert the message to a MIMEMultipart. (Default None)
:type reply_to: str
:param reply_to: Reply-to address (Default None)
"""

to = listify(to)
Expand All @@ -1551,6 +1554,9 @@ def send_mail(frm, to, subject, body, config, html=None):
msg.attach(mp_text)
msg.attach(mp_html)

if reply_to:
msg["Reply-To"] = reply_to

smtp_ssl = asbool(getattr(config, "smtp_ssl", False))
if smtp_ssl:
s = smtplib.SMTP_SSL(config.smtp_server)
Expand Down

0 comments on commit d33c534

Please sign in to comment.