php + hml email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

php + hml email

Post 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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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().
Post Reply