smisch commented on issue #23247:
URL: https://github.com/apache/superset/issues/23247#issuecomment-2049571431

   Thanks for the code. I had to make some slight adjustments in 2024 to make 
it work:
   
   ```
   import re
   from email.mime.multipart import MIMEMultipart
   from email.mime.text import MIMEText
   from typing import Any
   
   def EMAIL_HEADER_MUTATOR(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':
               payload = part.get_payload(decode=True).decode()  # Extract text 
content
               payload = re.sub('<a.*?>|</a>', '', payload)  # Apply regular 
expression
               part.set_payload(payload)  # Set the modified payload back to 
the part
   
       return msg
   ```
   
   It was complaining about `'expected string or bytes-like object'` with the 
original code due to `part` not being `string or bytes-like object`. 
   
   For those of us using the superset helm charts, just add this to 
`configOverrides.foobar` via `values.yaml` to the `superset_config.py`. 
   
   Btw. the disclaimer didn't show up in the mail, but the link removal stuff 
works great.


-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to