Added: Oct 29, 2020
Snippet uploaded by: snippet
Written By: snippet
Demo: Sorry, no demo
Thank you for your vote. Please wait...
It appears you already voted for this snippet
It appears your vote value was empty
Very basic form to show you how to send html based email. Remember that not everybody can view html email.
$to = "firstname.lastname@example.org";
$subject = "Test html based email";
// your message is now in HTML
$msg = "
<H1 ALIGN="CENTER">Look how cool this is!</H1>
/* to adhere to the standards defined in RFC 5321 and RFC 5322
The email client must meet the following criteria:
The header lines of the email must contain exactly one valid "Date" line according to RFC 2822.
The following header lines may only exist once: From, Sender, To, CC, Subject
The header lines mentioned must be syntactically correct
Note: The To and CC lines can contain multiple recipients.
// add email header
$header = "Content-type:text/html;charset=UTF-8" . "\r\n";
// add the from line
$header .= "From: mycompany.com <email@example.com>\r\n";
// to be RFC 2822 compliant you must have a date in the header
$header .= "Date: " .date("D, d M Y H:i:s O");
mail($to, $subject, $msg, $headers);
Subject: form in html email[ Reply ]
Comment By: on 19th of April 2007 07:54 PM
I want to add a form to an html email - is that possible?
Subject: form in html?[ Reply ]
Comment By: snippet on 20th of April 2007 07:19 AM
You can add anything you want to the email. Just add the form to the $msg variable with all of the html already there. In the end it is all html anyway.
$msg = "
<H1 ALIGN=CENTER>Look how cool this is!</H1>
Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.
Adding your comment. Please wait...
Thanks for adding your comment!. After further review it will be added.
There was a problem adding your comment. Please try again.
Please complete all the fields in the form before sending.