Location: PHPKode > scripts > dSendMail2 > dsendmail2-2-0/example-HTMLTemplate.php
<?php
require_once "dSendMail2.inc.php";

// First of all: DISABLE TIME LIMIT and IGNORE USER ABORT! You really don't want to be interrupted in the middle of this.
set_time_limit(0);
ignore_user_abort(true);



// Ok, let's say all your e-mails have a default header and a footer.
// So, you may re-write your "mail()" function...
function myMail($to, $subject, $message){
	$m = new dSendMail2;
	$m->setFrom("hide@address.com");
	$m->setTo($to);
	$m->setSubject($subject);
	
	$myTemplate = dirname(__FILE__)."/mail_template.html");
	$m->setHTMLFile($myTemplate); // Automatically import HTML and ALL IMAGES USED.
	
	// Your message doesn't come in HTML format?!
	$message = nl2br($message);
	
	// You can replace your message here:
	$m->html = str_replace("[MESSAGE]", $message, $m->html);
	
	return $m->send();
}

// Then...
myMail(
	"hide@address.com",
	"Thanks for contacting us...",
	"We received your message and will reply you as soon as we can.\r\n".
	"\r\n".
	"Thanks and come back later!"
);
Return current item: dSendMail2