doubledee Posted September 11, 2011 Share Posted September 11, 2011 Is there a way to add an HTML link in a Text E-mail that was generated by PHP? I am trying to create an e-mail that looks like this... Dear Member, Your password was re-set, and the following Temporary Password has been assigned: Use this temporary password to Log In. Debbie Quote Link to comment https://forums.phpfreaks.com/topic/246883-add-a-link-in-a-text-email/ Share on other sites More sharing options...
darkfreaks Posted September 11, 2011 Share Posted September 11, 2011 <?php $link="http://mysite.com/link/to/url"; $message= <<<EOD Dear Member,<br />Your password was reset, a Temporary Password has been assigned click this link to <a href="$link">login</a>. EOD;?> Quote Link to comment https://forums.phpfreaks.com/topic/246883-add-a-link-in-a-text-email/#findComment-1267902 Share on other sites More sharing options...
doubledee Posted September 11, 2011 Author Share Posted September 11, 2011 <?php $link="http://mysite.com/link/to/url"; $message= <<<EOD Dear Member,<br />Your password was reset, a Temporary Password has been assigned click this link to <a href="$link">login</a>. EOD;?> What is <<<EOD ??? How well supported is that code? Does it work in all/most e-mail clients that are in Text-Only e-mail mode? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/246883-add-a-link-in-a-text-email/#findComment-1267905 Share on other sites More sharing options...
darkfreaks Posted September 11, 2011 Share Posted September 11, 2011 The PHP heredoc string syntax allows free form text to be used without having to worry about escaping special characters such as quotes and backslashes. The content of the heredoc string is wrapped with <<<EOD and EOD; markers. The only rules are that the closing EOD; must be at the beginning of the last line. and no it will not show in a text only email the content type will have to be specified as html. Quote Link to comment https://forums.phpfreaks.com/topic/246883-add-a-link-in-a-text-email/#findComment-1267906 Share on other sites More sharing options...
doubledee Posted September 11, 2011 Author Share Posted September 11, 2011 The PHP heredoc string syntax allows free form text to be used without having to worry about escaping special characters such as quotes and backslashes. The content of the heredoc string is wrapped with <<<EOD and EOD; markers. The only rules are that the closing EOD; must be at the beginning of the last line. and no it will not show in a text only email the content type will have to be specified as html. But I asked how to make a link in my e-mail like this: Log In So Heredoc won't address that issue? Aren't all e-mails "text-only" by default? Like isn't my Gmail e-mail text only? It looks that way. Debbie Quote Link to comment https://forums.phpfreaks.com/topic/246883-add-a-link-in-a-text-email/#findComment-1267909 Share on other sites More sharing options...
darkfreaks Posted September 11, 2011 Share Posted September 11, 2011 So how do you properly send an HTML email along with a plain-text alternative version? Simple. You send it in "Multipart/Alternative MIME" format. If you're a programmer, this is where the gears in your brain start spinning. Now, go on and Google "multipart alternative" and figure out how to send them from your own server. You may find some PHP or Coldfusion or ASP scripts out there. Quote Link to comment https://forums.phpfreaks.com/topic/246883-add-a-link-in-a-text-email/#findComment-1267910 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.