Search code examples
phphtmlemailgmail-imap

Reply to email - dealing with the HTML


I have a PHP script that checks Gmail for new mail, then depending on the conditions of the email, will reply to the email with some information.

My question is when replying to an HTML email, what is the best way to deal with the HTML? Should I find the position of where the tag ends and then just insert my HTML code there after that?

I'm curious how an email client handles this when I hit Reply.

Thanks.


Solution

  • I would check if the email contains a plain-text version of the email and reply to that.

    Outside of that -- ignore "proper" html. Find the beginning of their email (be it <html> or <p>) Add your reply followed by <hr /><strong>Original Message...etc before that and be done.

    Good luck