glenelkins Posted June 4, 2006 Share Posted June 4, 2006 HiI want to send HTML emails using the information from a premade HTML page. The code to send the mail (testing is):[code]sendTemplate($template_folder,$template_filename,"[email protected]","Testing","From: [email protected]\r\n Content-type: text/html\r\n") [/code]The function (sendTemplates)[code]// Send Template function sendTemplate ($template_folder,$template_filename,$recipient,$title,$headers) { $email_body = file_get_contents($template_folder.$template_filename); if (!(mail ($recipient,$title,$email_body,$headers))) { return(false); } else { return(true); } }[/code]This always seems to send the emails displaying the whole html code, what am i doing wrong??cheers Link to comment https://forums.phpfreaks.com/topic/11152-html-emails/ Share on other sites More sharing options...
stephenk Posted June 4, 2006 Share Posted June 4, 2006 Have a look at [a href=\"http://www.webhostingtalk.com/archive/thread/416467-1.html\" target=\"_blank\"]http://www.webhostingtalk.com/archive/thread/416467-1.html[/a]Notice the <<EOF and EOF; tagsStephen Link to comment https://forums.phpfreaks.com/topic/11152-html-emails/#findComment-41694 Share on other sites More sharing options...
glenelkins Posted June 4, 2006 Author Share Posted June 4, 2006 iv tried that, if i use for example mail("[email protected]","Title",<<<EOF MESSAGE INFO EOF;,"headers");causes an error with the <<<EOFParse error: parse error, unexpected T_SL in /home/fhlinux188/g/gewebsitedevelopment.com/user/htdocs/tester.phpeven if i create a variable for it like:$message = <<<EOF <html bla blab balaldfjhbg EOF; Link to comment https://forums.phpfreaks.com/topic/11152-html-emails/#findComment-41696 Share on other sites More sharing options...
stephenk Posted June 4, 2006 Share Posted June 4, 2006 Did you try setting the message body as a variable, then referring to the variable in the mail() function? Link to comment https://forums.phpfreaks.com/topic/11152-html-emails/#findComment-41700 Share on other sites More sharing options...
glenelkins Posted June 4, 2006 Author Share Posted June 4, 2006 here is an example of how i would do it, that does not work:[code]$recipient = "[email protected]";$title = "Test";$from = "[email protected]";$headers = "From: " . $from;$header .= "Content-Type: text/html";$body = <<<EOF <html> <body> <p align="center"> Random Garbage Text </p> </body> </html>EOF;mail ($recipient,$title,$body,$headers);[/code]Not getting a parse error with this, but the email is coming through just showing the html tags, not the actual contentit works if i put \r\n in the headers. What is "\r" ??? not sure what that one does Link to comment https://forums.phpfreaks.com/topic/11152-html-emails/#findComment-41703 Share on other sites More sharing options...
kenrbnsn Posted June 4, 2006 Share Posted June 4, 2006 Your webserver is probably running on a Windows box. On Windows, the newline character is "\r\n", on Unix/Linux it is "\n" and, I believe, on a Mac it is "\r".Ken Link to comment https://forums.phpfreaks.com/topic/11152-html-emails/#findComment-41718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.