html format on email response form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
samohtwerdna
Forum Newbie
Posts: 2
Joined: Tue Jul 26, 2005 10:23 am
Location: Denver, Colorado

html format on email response form

Post by samohtwerdna »

Hello all,

I have a simple request for information form on my web site Contact

I would like to do more than simple html tags to format the email response, like maybe use some CSS for some containers.

Here is the format portion of my php script:

Code: Select all

//**********************************************************/	
	/* START EMAIL FORMAT */
	if(!$error) {
		$msg .= "\n\n<h4>THE KITCHEN STRAND CONTACT FORM</h4>\n";
		$msg .= "\n\n<p><i>This is the information filled out by:</i></p><br />\n";
		
		$msg .= $name . "\n";		
		$msg .= "\n\n-<br />\n";
		$msg .= "\n\n------------------------<br />\n";
			
		$msg .= "Address:<br /> " . $addr1 . "\n";
		$msg .= "\n\n<br />\n";
		$msg .= $city . " " . $state . " " . $zip . "\n";
		$msg .= "\n\n------------------------<br />\n";
		$msg .= "Phone:<br /> " . $phone . "\n";
		$msg .= "\n\n<br />\n";
		$msg .= "\n\n<h5>--- Comments: ---</h5>\n";
		
		if($comments != '') {
			$msg .= $comments . "\n";
			}
		$msg .= "\n\n<br />\n";
		$msg .= "\n\n------------------------<br />\n";
		$msg .= "\n\n<h5>--- RETURN ADDRESS: ---</h5>\n";
		
		if($email != '') {	 
			$msg .= $email . "\n";
			}
		$msg .= "\n\n<br />\n";	
		$msg .= "\n\n------------------------<br />\n";

		$subject .= "Kitchen Strand Contact Us Form";
		$to .= "fred@kitchenstrand.us";				/*change value to as many accounts as desired just add a comma, space and keep accounts with in one set of " "*/
		$headers .= "From: ". $name . " <$email>\r\n"; 
		$headers .= "Reply-To: ". $name . " <$email>\r\n"; 
		$headers .= "X-Priority: 0\r\n"; 
		$headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
		$headers .= "bcc:andy@wmohs.com, dadcock658@aol.com\n"; // BCCs to
		mail($to,$subject,$msg,$headers);
		$sent = true;
		
//**********************************************************/		
		
		/* END EMAIL FORMAT */

//**********************************************************/
		
		}
	}
Any suggestions??

Thanks
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

I think including MIME version is compulsory.

Code: Select all

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html;
samohtwerdna
Forum Newbie
Posts: 2
Joined: Tue Jul 26, 2005 10:23 am
Location: Denver, Colorado

Post by samohtwerdna »

ok so the MIME version allows me to format the mail with CSS?

If so how do I insert the CSS, and can I use <div> tags to organize my content?

Like:

Code: Select all

//**********************************************************/ 

/* START EMAIL FORMAT */

if(!$error) {

$msg .= "\n\n<h4>THE KITCHEN STRAND CONTACT FORM</h4>\n";

$msg .= "\n\n<div id="main"><p><i>This is the information filled out by:</i></p><br />\n";

/*ect*/
$msg .= $name . "\n"; 

$msg .= "\n\n<br />\n"; 

$msg .= "\n\n------------------------<br /></div>\n";

/*ect*/

$headers .= 'MIME-Version: 1.0' . "\r\n"; 

$headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type


mail($to,$subject,$msg,$headers);

$sent = true;


//**********************************************************/ 


/* END EMAIL FORMAT */

//**********************************************************/


}

}
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

samohtwerdna wrote: ok so the MIME version allows me to format the mail with CSS?
I had pondered over this a long ago only to find out that most email readers dont parse CSS - just HTML tags.
Post Reply