[FX.php List] How to send HTML emails in PHP
Bob Patin
bob at patin.com
Thu Jan 24 13:24:55 MST 2008
Jon,
Didn't work...
My email body is called $body;
I tried putting "ob_start();" before the construction of the mail
body, and then "$body=ob_get_clean();" after it, but all I got was a
blank page.
Here's my PHP:
<?php
ob_start();
$body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//
EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
$body = $body."\r\n".'<html xmlns="http://www.w3.org/1999/xhtml">';
$body = $body."<head>";
$body = $body.'<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />';
$body = $body.'<title>Untitled Document</title>';
$body = $body.'</head>';
$body = $body.'<body>';
$body = $body.'<img src="http://comparisons.advantastar.com/images/logo.jpg
" width="376" height="55" />';
$body = $body.'</body>';
$body = $body.'</html>';
$body = ob_get_clean();
//SOCK MAIL FUNCTION
include_once('mail_function.php');
$to="bob at patin.com";
$from="info at longtermsolutions.com";
$subject="Web Inquiry";
$replyto=$from;
sock_mail(1, $to, $subject , $body, $replyto , $from);
?>
On Jan 24, 2008, at 2:15 PM, Jon Montgomery wrote:
> Try this:
>
> At the start of your pretty html put <?php ob_start(); ?>
>
> Then put you html and php or whatever you want to show.
>
> Then put:
> <?php $custom_email = ob_get_clean(); ?>
>
> Then that variable is the body. Now I will tell you that I use this
> in FMStudio for the custom email body using the Email module that
> works with it. But I am assuming that it will work fine in any PHP
> since it is PHP code. At least this is what works for me.
>
> Jon Montgomery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20080124/0a4fb70f/attachment.html
More information about the FX.php_List
mailing list