Jump to content


Photo

HTML EMAILS


  • Please log in to reply
5 replies to this topic

#1 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 04 June 2006 - 01:16 PM

Hi

I want to send HTML emails using the information from a premade HTML page. The code to send the mail (testing is):

sendTemplate($template_folder,$template_filename,"glen@gewebsitedevelopment.com","Testing","From: noreply@gewebsitedevelopment.com\r\n Content-type: text/html\r\n")

The function (sendTemplates)

// 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);
        }
    }

This always seems to send the emails displaying the whole html code, what am i doing wrong??

cheers
http://thewebsolutionprovider.com - A Solution For Everything Web!

#2 stephenk

stephenk
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 04 June 2006 - 01:31 PM

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; tags

Stephen

#3 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 04 June 2006 - 01:42 PM

iv tried that, if i use for example mail("recipient@wotever.com","Title",<<<EOF MESSAGE INFO EOF;,"headers");

causes an error with the <<<EOF

Parse error: parse error, unexpected T_SL in /home/fhlinux188/g/gewebsitedevelopment.com/user/htdocs/tester.php

even if i create a variable for it like:

$message = <<<EOF <html bla blab balaldfjhbg EOF;
http://thewebsolutionprovider.com - A Solution For Everything Web!

#4 stephenk

stephenk
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 04 June 2006 - 01:43 PM

Did you try setting the message body as a variable, then referring to the variable in the mail() function?

#5 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 04 June 2006 - 01:54 PM

here is an example of how i would do it, that does not work:

$recipient = "noone@woteva.com";
$title = "Test";
$from = "noone@youremai..com";
$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);

Not getting a parse error with this, but the email is coming through just showing the html tags, not the actual content

it works if i put \r\n in the headers. What is "\r" ??? not sure what that one does
http://thewebsolutionprovider.com - A Solution For Everything Web!

#6 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 04 June 2006 - 02:38 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users