amartincolville opened a new issue, #23247:
URL: https://github.com/apache/superset/issues/23247

   I am trying to modify the email that is being sent out by a scheduled 
Report. For this, I am using the 
[EMAIL_HEADER_MUTATOR](https://github.com/apache/superset/blob/master/superset/config.py#L1209)
 environment variable in the config, and I basically would like to modify the 
mime message in the following manner:
   
   1. Remove the Explore in Superset hyperlink
   2. Add a footer or signature to all emails as a disclaimer
   
   After checking what is being done in the underlying 
[code](https://github.com/apache/superset/blob/master/superset/utils/core.py#L994),
  I believe a simple mutator function would suffice in the image config file we 
are using, although it does not work at all and the outgoing message never 
mutates as it should be doing because the content is altered and returned. 
   
   Did anybody stumbled upon a similar issue or used EMAIL_HEADER_MUTATOR?
   
   #### How to reproduce the bug
   
   In the dockerised superset image config file:
   
   ```
   def EMAIL_HEADER_MUTATOR(  # pylint: disable=invalid-name,unused-argument
       msg: MIMEMultipart, **kwargs: Any
   ) -> MIMEMultipart:
       disclaimer = "<i>Please do not reply, this is an automatically generated 
email.</i>"
       mime_text = MIMEText(disclaimer, "html")
       msg.attach(mime_text)
   
       # Remove all anchor tags from message payload
       for part in msg.walk():
           if part.get_content_type() == 'text/html':
               part.set_payload(re.sub('<a.*?>|</a> ', '', part))
   
       return msg
   ```
   
   ### Expected results
   
   Mutated message:
   1. Text _"Please do not reply, this is an automatically generated email."_ 
should appear at the end of each email
   2. All anchor tags should be removed from the email contents (on all parts)
   
   ### Actual results
   
   Email does not mutate at all - no changes and no errors are logged.
   
   #### Screenshots
   
   If applicable, add screenshots to help explain your problem.
   
   
   ### Environment
   
   (please complete the following information):
   
   - browser type and version: Chrome 110.0.5481.177
   - superset version: `2.0`
   - python version: `3.9`
   - node.js version: N/A
   - any feature flags active:
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [x] I have checked the superset logs for python stacktraces and included 
it here as text if there are any.
   - [x] I have reproduced the issue with at least the latest released version 
of superset.
   - [x] I have checked the issue tracker for the same issue and I haven't 
found one similar.
   
   ### Additional context
   
   Add any other context about the problem here.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to