0

Is there a plugin or hack for thunderbird that strips out all HTML tags?

For example, if I receive an email that has the following content in the body of the email:

<html xmlns=3D"http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8=
"/>
    <style type=3D"text/css">
        body {
            margin:0;
            color:#333;
        }

        a {
            text-decoration:none;
            color:#006699;
        }

        p {
            margin:0px;
        }

        img {
            border:0;
            margin:0;
            text-align: center;
        }

        #title p{
            font-size:15px;
            font-family: "Our Ember", Arial, sans-serif;
        }

    </style>
    <title></title>
</head>
<body><img width=3D"1" height=3D"1" src=3D"https://www.example.com/gp/r.html=
?C=3D1BDNQAME26BY1&M=3Durn:rtn:msg:20210814073749c3222ee107f04186b9d218a2d6=
30p0na&R=3D7KE509NKJXP3&T=3DP&U=3Dhttps%3A%2F%2Fimages-na.ssl-images-our=
.com%2Fimages%2FG%2F01%2Fnav%2Ftransp.gif&H=3DG774NKHTYQC3WGV9A1QIE4DWIVQA&=
ref_=3Dpe_2429110_469155610_opens" />
<table align=3D"center" cellspacing=3D"0" width=3D"520" cellpadding=3D"0" s=
tyle=3D"padding-bottom: 20px;">
    <tbody>
        <tr>
            <td>
                <table cellspacing=3D"0" width=3D"520" cellpadding=3D"0" st=
yle=3D"margin-top:0px; margin-bottom: 0px; margin-left: 20px; margin-right:=
 20px;">
                    <tbody>
                    <tr width=3D"520">
                        <td width=3D"520" height=3D"52" style=3D"border-bot=
tom:1px solid #eaeaea; padding-top:10px;">
                            <table>
                                <tr width=3D"520">
                                    <td width=3D"107" id=3D"logo">
                                        <img id=3D"blah" alt=3D"Lo=
go Image" width=3D"107" height=3D"auto" src=3D"https://m.example.com/i=
mages/G/01/authportal/tiv/our_logologo_RGB._CB424581820_.png"/>
                                    </td>
                                    <td align=3D"left" valign=3D"top" style=3D"font-family: Connections, =
'Calibri', Arial, Helvetica, sans-serif; padding: 20px 20px 0px 20px;"><p s=
tyle=3D"font-family: Connections, 'Calibri', Arial, Helvetica, sans-serif; =
font-size: 16px; color: #000000; mso-line-height-rule: exactly; line-height=
: 140%; Margin: 0; padding: 0; webkit-font-variant-ligatures: no-common-lig=
atures; font-variant-ligatures: none;"> 
                                </tr>
                            </table>
                        </td>
                    </tr>
                        <tr>
                            <td colspan=3D"2" align=3D"left" style=3D"text-=
align: left; font-size:17px; font-family: 'Our Ember', Arial, sans-serif=
; padding-top: 15px; padding-bottom: 0px; padding-left: 0px; padding-right:=
 1px;"><p>Dear customer,</p></td></tr><tr>
                        <td colspan=3D"2" align=3D"left" style=3D"text-alig=
n: left; font-size:17px; font-family: 'Our Ember', Arial, sans-serif; pa=
dding-top: 15px; padding-bottom: 10px; padding-left: 0px; padding-right: 1p=
x;"><p>Your OTP is 123456</p></td></tr>

...

I would want the email to be rendered as, roughly



    
    
    
    

    
        
            
                
                    
                    
                        
                            
                                
                                    
                                    
                                
                            
                        
                    
                        
                            
                    

                            Dear customer,

                        
                        
                        
                        
                        
                        
                            Your OTP is 123456


...

For security and privacy reasons, I disable HTML rendering in thunderbird.

While some email senders rightly define both a Content-Type: text/html; and Content-Type: text/plain; mimeparts of the email body, it's becoming increasingly popular for many businesses not to do so.

Moreover, it's becoming increasingly popular for services to send OTP codes on every login to email (setting aside the absurdity mandating an authentication credential that's sent over an insecure medium without offering something like TOTP as 2FA to their customers..)

Consequently, it's not uncommon for me to spend 90% of the time I spend trying to authenticate into a website just scrolling through hundreds of lines of css and html tables trying to find the 6-digit plaintext OTP needle in a sea of html nonsense.

Is there a very simple thunderbird plugin or hack that will not "render" the html and try to convert it to plaintext, but just very dumbly detect html tags and remove them?

0

I don't know how to do this with thunderbird, but I wrote a very simple python script to strip HTML with BeautifulSoup

Prereqs

On Debian, first install the python dependencies

sudo apt-get install python3 python3-bs4

Create the script

cat > fu-html.py <<'EOF'
#!/usr/bin/env python3

import sys 
from bs4 import BeautifulSoup

print( "Enter html below:" )
html_doc = sys.stdin.readlines()

soup = BeautifulSoup( ''.join(html_doc), 'html.parser' )

print( 'Plaintext:' )
print( '-------------------------------------------------------------------------------' )
print( soup.get_text() )

EOF
chmod +x fu-html.py

Example Execution

Now you can execute the script. When prompted, just paste the snippet of HTML into the terminal and press ctrl+D to send signalEOF.

root@disp7899:~# ./fu-html.py
Enter html below:
<html xmlns=3D"http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8=
"/>
    <style type=3D"text/css">
        body {
            margin:0;
            color:#333;
        }

        a {
            text-decoration:none;
            color:#006699;
        }

        p {
            margin:0px;
        }

        img {
            border:0;
            margin:0;
            text-align: center;
        }

        #title p{
            font-size:15px;
            font-family: "Our Ember", Arial, sans-serif;
        }

    </style>
    <title></title>
</head>
<body><img width=3D"1" height=3D"1" src=3D"https://www.example.com/gp/r.html=
?C=3D1BDNQAME26BY1&M=3Durn:rtn:msg:20210814073749c3222ee107f04186b9d218a2d6=
30p0na&R=3D7KE509NKJXP3&T=3DP&U=3Dhttps%3A%2F%2Fimages-na.ssl-images-our=
.com%2Fimages%2FG%2F01%2Fnav%2Ftransp.gif&H=3DG774NKHTYQC3WGV9A1QIE4DWIVQA&=
ref_=3Dpe_2429110_469155610_opens" />
<table align=3D"center" cellspacing=3D"0" width=3D"520" cellpadding=3D"0" s=
tyle=3D"padding-bottom: 20px;">
    <tbody>
        <tr>
            <td>
                <table cellspacing=3D"0" width=3D"520" cellpadding=3D"0" st=
yle=3D"margin-top:0px; margin-bottom: 0px; margin-left: 20px; margin-right:=
 20px;">
                    <tbody>
                    <tr width=3D"520">
                        <td width=3D"520" height=3D"52" style=3D"border-bot=
tom:1px solid #eaeaea; padding-top:10px;">
                            <table>
                                <tr width=3D"520">
                                    <td width=3D"107" id=3D"logo">
                                        <img id=3D"blah" alt=3D"Lo=
go Image" width=3D"107" height=3D"auto" src=3D"https://m.example.com/i=
mages/G/01/authportal/tiv/our_logologo_RGB._CB424581820_.png"/>
                                    </td>
                                    <td align=3D"left" valign=3D"top" style=3D"font-family: Connections, =
'Calibri', Arial, Helvetica, sans-serif; padding: 20px 20px 0px 20px;"><p s=
tyle=3D"font-family: Connections, 'Calibri', Arial, Helvetica, sans-serif; =
font-size: 16px; color: #000000; mso-line-height-rule: exactly; line-height=
: 140%; Margin: 0; padding: 0; webkit-font-variant-ligatures: no-common-lig=
atures; font-variant-ligatures: none;"> 
                                </tr>
                            </table>
                        </td>
                    </tr>
                        <tr>
                            <td colspan=3D"2" align=3D"left" style=3D"text-=
align: left; font-size:17px; font-family: 'Our Ember', Arial, sans-serif=
; padding-top: 15px; padding-bottom: 0px; padding-left: 0px; padding-right:=
 1px;"><p>Dear customer,</p></td></tr><tr>
                        <td colspan=3D"2" align=3D"left" style=3D"text-alig=
n: left; font-size:17px; font-family: 'Our Ember', Arial, sans-serif; pa=
dding-top: 15px; padding-bottom: 10px; padding-left: 0px; padding-right: 1p=
x;"><p>Your OTP is 123456</p></td></tr>
Plaintext:
-------------------------------------------------------------------------------




        body {
            margin:0;
            color:#333;
        }

        a {
            text-decoration:none;
            color:#006699;
        }

        p {
            margin:0px;
        }

        img {
            border:0;
            margin:0;
            text-align: center;
        }

        #title p{
            font-size:15px;
            font-family: "Our Ember", Arial, sans-serif;
        }

    






















Dear customer,
Your OTP is 123456

root@disp7899:~# 

As you can see, all of the html tags (not the CSS in-between the HTML tags) is stripped away, making it much easier for a human to read the text contents of the email

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.