Hiding unsubscription and View it online links when viewing newsletter online
<p>I have this case. I have a site that is sending newsletters to subscribers. The email template is generated by a PHP template (e.g. single-newsletter.php)</p>

<p>When a user receives this newsletter in his email client, he/she can read the content as well as see these links:</p>

<p>a.) Link to view the newsletter online (This online content is still using single-newsletter.php template).</p>

<p>b.) Link to unsubscribe the newsletter.</p>

<p>Everything is perfect in the email side, so this is working as intended. </p>

<p>My problem is when a user clicks on the "View it online" link, the newsletter (which is now viewed online and not on his/her email client) still has the "view it online" and unsubscription links. I want these two links to be removed. Is there a easy and simple way (without side effects from my existing setup) that this can be remove when a user is viewing the newsletter online?</p>

<p>The email body is generated by doing a file_get_contents to the email template then put it on the $mail_body variable. I am thinking of using this condition in PHP:</p>

<pre><code>if (empty($_SERVER['HTTP_USER_AGENT'])) {

//no user agent, this is the file_get_contents reading it
//render the View it online and subscription links
//So it will appear in the email body

} else {

//user agent detected, must be a user reading this online with his browser
//Don't show the view it online and unsubscription links

}
</code></pre>

<p>Please let me know if this is a good solution, if you have other good solutions. Please share. Thanks.</p>

<p>Thanks for any tips.</p>
