Jump to content

Formatting PHP Form to Email


artstarved

Recommended Posts

I am trying to format this code so that it does not dump all of the text from different inputs into one garbled mess in the e-mail message. To do this I am trying to use html to add a header and line break so that the emails is formatted but it is just spitting my html out like it is plain text when I open the e-mail. Tags and all.

 

If anyone can help that would be great, I am pretty new to PHP.

 

Here is my PHP:

 

<?php

//Organization Name

$mail_from="$organization";

//Organization Telephone

$message.="$organization_phone";

//Organization Mail

$message.="$organization_mail";

//General Inquiries

$message.="$general_inquires";

// From

$header="from: $organization <$mail_from>";

// Enter your email address

$to ='dealers@countrydelights.ca';

// Variables

$message.=$var1.'<p>organization phone number</p><br>'.$var2.'<p>organization email</p><br>'.$var3.'<p>general inquiries</p><br>';

// Send Form

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email

// display message "We've recived your information"

if($send_contact){

echo "We've recived your contact information";

}

else {

echo "ERROR";

}

?>

Link to comment
Share on other sites

<?php
//Organization Name
$mail_from="$organization";
//Organization Telephone
$message.="$organization_phone";
//Organization Mail
$message.="$organization_mail";
//General Inquiries
$message.="$general_inquires";
// From
$header="From: $organization <$mail_from>\n".
"Content-type: text/html";
// Enter your email address
$to ='dealers@countrydelights.ca';
// Variables
$message.=$var1.'<p>organization phone number</p><br>'.$var2.'<p>organization email</p><br>'.$var3.'<p>general inquiries</p><br>';
// Send Form
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

You gotta specify Content-type in the headers.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.