Not a Member Yet,
Click here to Register

ID: 99
Viewed: 6857
Added: Oct 29, 2020
Version: 1.1
Snippet uploaded by: snippet
Written By: snippet
Demo: Sorry, no demo



User Rated at: 1 Stars
Rate This:

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.

<!---Head--->
none

<!---Body--->


 <?php

$to = "you@yoursite.com";
$subject = "Test html based email";

// your message is now in HTML
$msg = "
<HTML>
<HEAD>
<TITLE>My Message</TITLE>
</HEAD>
<BODY>
<H1 ALIGN="CENTER">Look how cool this is!</H1>
</BODY>
</HTML>
";

/* to adhere to the standards defined in RFC 5321 and RFC 5322

Solution:

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 <me@mycompany.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);

echo "finished!";

?>


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?
Christian

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 = "
<HTML>
<HEAD>
<TITLE>My Message</TITLE>
</HEAD>
<BODY>
<H1 ALIGN=CENTER>Look how cool this is!</H1>
<form>
....
</form>
</BODY>
</HTML>
";


Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


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.

© 2002 - 2024 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!