This is an automated email from the ASF dual-hosted git repository.

dill0wn pushed a commit to branch dw/8460
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 87bb912c6824342ff9c604faad545d23f15f841f
Author: Dillon Walls <[email protected]>
AuthorDate: Wed Sep 7 14:37:47 2022 +0000

    [#8460] add new email @task which sends an already formatted email content
---
 Allura/allura/lib/mail_util.py    | 8 ++++++--
 Allura/allura/tasks/mail_tasks.py | 7 +++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Allura/allura/lib/mail_util.py b/Allura/allura/lib/mail_util.py
index 374cb25ef..226a62b01 100644
--- a/Allura/allura/lib/mail_util.py
+++ b/Allura/allura/lib/mail_util.py
@@ -301,11 +301,15 @@ class SMTPClient:
             log.warning('No valid addrs in %s, so not sending mail',
                         list(map(str, addrs)))
             return
+
+        self.send(config.return_path, smtp_addrs, content)
+
+    def send(self, addr_from, smtp_addrs, content):
         if not self._client:
             self._connect()
         try:
             self._client.sendmail(
-                config.return_path,
+                addr_from,
                 smtp_addrs,
                 content)
             need_retry = False
@@ -322,7 +326,7 @@ class SMTPClient:
             # maybe could sleep?  or if we're in a task, reschedule it somehow?
             self._connect()
             self._client.sendmail(
-                config.return_path,
+                addr_from,
                 smtp_addrs,
                 content)
 
diff --git a/Allura/allura/tasks/mail_tasks.py 
b/Allura/allura/tasks/mail_tasks.py
index 541f47184..dda48888e 100644
--- a/Allura/allura/tasks/mail_tasks.py
+++ b/Allura/allura/tasks/mail_tasks.py
@@ -246,6 +246,13 @@ def sendsimplemail(
         in_reply_to, multi_msg, sender=sender, references=references, cc=cc, 
to=toaddr)
 
 
+@task
+def send_raw_content(mail_system, addr_from, addr_to, full_email_content):
+    log.info("send_raw_content {} from: {} to: {}".format(mail_system, 
addr_from, addr_to))
+    if mail_system == 'local':
+        smtp_client.send(addr_from, [addr_to], full_email_content)
+
+
 def send_system_mail_to_user(user_or_emailaddr, subject, text):
     '''
     Sends a standard email from the Allura system itself, to a user.

Reply via email to