Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I display email in the browser securely with acure styling?

I'm currently working on a application which includes the functionality to display email in a web gui and now I'm wondering what's best practice for displaying email in a web browser, first I though that I should use an iframe but when looking in the source of the major web mail clients they don't seem to use iframes so that's why I'm asking here. I'm worried that styles and scripts from the mail will affect the rest of my site (also xss) but I still want the emails to be shown the way they are intended to be shown.

like image 485
Hultner Avatar asked Dec 18 '25 13:12

Hultner


1 Answers

Major (web)mail clients will remove some portions of your code. Like background-images from tables, style applied to the body tag, remove javascript, etc. They do that to ensure it won't affect their own design and functionalities.

You have to do the same.

You would most certainly have a div where you put your cleaned email body. How you clean the email body is up to what you agree to allow...

like image 72
Michel Avatar answered Dec 21 '25 03:12

Michel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!