So I have a PHP script which takes in piped emails, appends a footer to them and passes them on.
But if someone sends an email which is already in HTML format it just inserts the entire html email into the body of a new html document. I need a script which will (if the email is already in HTML) take off the html, head and body tags leaving the original email.
I.e. if someone sent an email
<html><body>This is my awesome input email which is <strong>already</strong> in HTML</body></html> It is parsed by my script to become
<html><body><html><body>This is my awesome input email which is <strong>already</strong> in HTML</body></html></body></html> How can I get it to take off the HTML structure if it exists?