Jump to content

Archived

This topic is now archived and is closed to further replies.

glenelkins

HTML EMAILS

Recommended Posts

Hi

I 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,"glen@gewebsitedevelopment.com","Testing","From: noreply@gewebsitedevelopment.com\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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
Did you try setting the message body as a variable, then referring to the variable in the mail() function?

Share this post


Link to post
Share on other sites
here is an example of how i would do it, that does not work:

[code]
$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);
[/code]

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.