RE: [PHP] HTML Email
| From: | Grant Walters | Date: | Fri, 25 Aug 2000 21:39:36 +0000 |
| Subject: | RE: [PHP] HTML Email | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13744@lists.php.net to get a copy of this message | ||
Try these. Modify the HTML Code accordingly. I am building the response
string as both the content of the response page and the email message. I
use field names in the form starting with IGNORE to skip fields I don't want
in the actual output.
Note that the MIME-Version String is crucial, apparently.
//site->mailheaders contains this
// "From:
webmaster@walters.co.nz\nReply-To:webmaster@walters.co.nz\nMIME-Version:
1.0\nContent-Type: Text/HTML\n"
function
mail_it($form_name,$mail_message,$mail_to="Grant.Walters@walters.co.nz") {
global $site;
if (mail($mail_to,"$form_name
Submission",$mail_message,$site->mail_headers)) {
return TRUE;
} else {
return FALSE;
}
}
// passed_array is actually HTTP_POST_VARS
function build_form_response($passed_array="",$form_name="Unknown Form") {
if (is_array($passed_array)) {
$form_response="<HTML><HEAD><TITLE>Form Submission:
$form_name</TITLE></HEAD><BODY>";
$form_response .= "<p class=yellow3>Thank You</p>";
$form_response .= "<p>We will process your request and you will
receive acknowledgement within the next few days.</p>";
$form_response .= "<table border=0 width=100% cellspacing=10><tr
valign=top>";
$form_response .= "<th valign=top align=left colspan=2>The following
details have been submitted:</th><tr>";
while ( list ( $header , $value ) = each ($passed_array)) {
if (("$header"=="Required_Fields") ||
(substr($header,0,6)=="IGNORE")) { // NEED TO HANDLE REQUIRED FIELDS AND
IGNORED FIELDS
} else {
if (!empty($value)) {
$form_response .= "<tr><td align=right width=30%
valign=top>".str_replace("_","
",$header)." </td><td valign=top>";
if (is_array($value)) {
while ( list ( $header1 , $value1 ) = each ($value)) {
$form_response .= "$value1 ";
}
} else {
$form_response .= "$value ";
}
$form_response .= "</td></tr>";
}
}
}
$form_response .= "</table></BODY></HTML>";
return $form_response;
}
}
Regards
GRANT WALTERS
Walters & Associates, P O Box 13-043, Johnsonville, Wellington, New Zealand
Phone: +64 4 4765175 CellPhone: 025 488265
> Where exactly do you put this :
> Content-Type: text/html;
> charset=iso-8859-1;
> to send an html email? where is this header situated
> and how?
>
>
> --- "TaoX { Brian Hinson; }" <brianh@rjsonline.net>
> wrote:
> > I just use the mail function if php because I have
> > sendmail installed....
> > but this is all you have to add to the Header to
> > send html email...
> >
> >
> >
> > now the body of the message can be all html...
> >