sending a .PHP page as HTML using phpmailer
Posted: Tue Aug 09, 2005 8:10 pm
I'm using phpmailer to send newsletter from a company to its employees. The contents of the newsletter are read from a database and inserted in a template page using PHP.
The problem that I'm facing is that I have coded the entire template page inside the page that sends the newsletter. It is something like this:
This is very cumbersome... Every change I have to make to the newsletter is hell. I have to build it in a separated file (for previewing purpouse) and then bring it inside the page that sends the newsletter (escaping every quote and other things).
There has got to be an easier way of doing this. Any help is greatly appreciated.
Thanks a lot,
HEMOglobina
PS: The page that I want to send is full of PHP commands that reads from the DB... just in case this matters.
The problem that I'm facing is that I have coded the entire template page inside the page that sends the newsletter. It is something like this:
Code: Select all
$html = "<html><head><title>Newsletter</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head>";
$html .= "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#000000\" vlink=\"#000000\" alink=\"#000000\" leftmargin=\"0\" topmargin=\"15\" marginwidth=\"0\" marginheight=\"0\"><font face=\"Arial, Helvetica, sans-serif\"><div align=\"center\">";
$html .= "etc etc etc";
// somewhere else in the code:
$mail = new PHPMailer();
$mail->Body = $html;
$mail->IsHTML(true);
...
$mail->Send();There has got to be an easier way of doing this. Any help is greatly appreciated.
Thanks a lot,
HEMOglobina
PS: The page that I want to send is full of PHP commands that reads from the DB... just in case this matters.