Remove clickable hyperlinks in email body

Peter H. Lemieux mailscanner at replies.cyways.com
Thu Apr 9 17:03:40 UTC 2020


This kind of thing is better handled by procmail, a replacement mail 
delivery agent that allows you to create mail-handling "recipes."  One 
type of recipe is a filter that can be applied to the text of a message. 
  Here's a simple filter I wrote that uses sed to disarm links by 
replacing the "<a" and "/a>" tags with "<axxx" and "/xxxa" respectively.

:0f
| sed 's%<a%<xxxa%g' | sed 's%/a>%/xxxa%g'

The :0 denotes the beginning of a recipe, and the "f" switch tells it 
act as a filter.  The message is passed through the two sed instances 
then delivered normally.

You can install procmail using your system's package manager, if you do 
not have it already.  You can place system-wide recipes in the file 
called /etc/procmailrc, and they will be applied to every delivered 
message.  Users can have their own individual .procmailrc files as well.

https://linux.die.net/man/5/procmailrc - documentation for writing 
recipes; very extensive and dense

https://linux.die.net/man/5/procmailex - much easier introduction 
through the use of common examples

Peter


On 4/9/20 11:26 AM, James Yu Wang wrote:
> Hello,
> 
> Is there a way to remove clickable hyperlinks in message body and still 
> keep the whole message in HTML format? Right now we convert all HTML to 
> Text format. Some emails are hard to read in text mode.


More information about the MailScanner mailing list