Page 1 of 1

php + hml email

Posted: Mon Nov 07, 2005 8:55 am
by hame22
Hi,

I am prooducing a script where I send a html email on a trigger.

At the moment I have the html embedded into the script, e.g.

Code: Select all

$message = '<html><body><H1>......etc'
is it possible to design a html email externally then include it into the script,

e.g.

Code: Select all

$message = include('email.php');
thanks in advance

Posted: Mon Nov 07, 2005 9:14 am
by onion2k
Sure.

Though you'll need to be careful how you build the email content if you use include(). You'll need to construct a string and then use return $string; at the end of the include to get it to work. EG:

Code: Select all

$string   = "Dear user,\n";
$string  .= "This is the email.\n";
$string  .= "It was sent at ".date("r")."\n";

return $string;
If the file is just static HTML you'd be better off using file_get_contents().