I am trying to send and email text or/and html versions..
What I do is this:
$bodyHTML = "
--PHP-alt-$random_hash
Content-Type: text/plain; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
http://example.com/app_dl.php?app_id=$_GET[app_id] to download your $app_name app \n\r
Want to get tons more hot apps for free! anywhere anytime? Download our app on http://example' \n\r\n\r
example.com team
--PHP-alt-$random_hash
Content-Type: text/html; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
<p><a href='http://example.com/app_dl.php?app_id=$_GET[app_id]'>Click Here</a> to download your $app_name app</p>
<p>Want to get tons more hot apps for free! anywhere anytime? Download our app on <a href='http://example.com'>example.com</a></p>
<br/>
<p>example.com team</p>
--PHP-alt-$random_hash ";
endif;
This is what I get:
--PHP-alt-f4b83c7072ae970392b44308a6c36109 Content-Type: text/plain; charset='iso-8859-
1' Content-Transfer-Encoding: 7bit http://example.com/app_dl.php?app_id=35 to download your PhoneMates app Want to get tons more hot apps for free! anywhere anytime? Download our app on http://example.com' example.com team --PHP-alt-f4b83c7072ae970392b44308a6c36109 Content-Type: text/html; charset='iso-8859-1' Content-Transfer-Encoding: 7bit
Click Here to download your PhoneMates app
Want to get tons more hot apps for free! anywhere anytime? Download our app on example.com
example.com team
--PHP-alt-f4b83c7072ae970392b44308a6c36109
The problem is that I see all those header lines..content type..and the text lines fail to be formatted with ‘\n\r’..
Also, I dont know if I can achieve the effect that if one version fails.. html or txt,,then the other version will appear.. thanks for the help
Here is some of the code:
$random_hash = md5(date('r', time()));
$boundary="PHP-alt-".$random_hash;
$headers = array ('From' => $from,
'Content-Type'=> 'multipart/alternative',
'boundary'=>$boundary,
'To' => $to,
'Return-Path' => 'info@example.com',
'Subject' => $subject);
Other details such as sender, pass , title,,arent relevant..so I didnt present them here..
Don’t roll your own MIME handling. Use a library instead of reinventing the wheel.
I understand that Swift is the usual option in PHP land.
That said, I suspect the problem has something to do with the whitespace before your MIME boundary markers and headers. Try removing it.
Also your last MIME boundary is missing the
--at the end.Really, really, use a robust, well tested, third party library for this stuff. There is just too much fiddly stuff you can get wrong.