PHP mail not sending returning blank page - php

this is my form. but it failed to send mail and it not showing any errors . send mail function working fine on server. how can i make it functional and I find that their details are being inserted into the form, but the email is not sending.
<?php
ob_start();
session_start();
$txtname = $_POST['txtname'];
$txtemail = $_POST['txtemail'];
$txtnumber = $_POST['txtnumber'];
$cbocountry = $_POST['cbocountry'];
$rooms = $_POST['rooms'];
$Arrivaldate = $_POST['Arrivaldate'];
$departure = $_POST['departure'];
$Houseboat = $_POST['Houseboat'];
$adults = $_POST['adults'];
$children = $_POST['children'];
$Bookingdetails = $_POST['Bookingdetails'];
$body="<b><u>ANGEL HOUSEBOATS</u></b><br><br>
<table border=\"0px\" bgcolor=\"#FFFFFF\">
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Name </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $txtname</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> E-mail </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $txtemail</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Telephone </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $txtnumber</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Country </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $cbocountry</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> No.of Rooms </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $rooms</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Arrival </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $Arrivaldate</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Departure </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $departure</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Houseboat </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $Houseboat</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Number of People </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> No.of Adults : $adults | No.of Childern : $children</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\"> Comments </td> <td bgcolor=\"#dcdcdc\"><font face=\"Arial\" size=\"2px\"><b> $Bookingdetails </b></font></td></tr>";
$headers = "Content-Type: text/html; charset=iso-8859-1"."\r\n"."From: $txtemail" . "\r\n" .
"Reply-To: $txtemail" . "\r\n"
;
$to="myemail#gmail.com";
$subject="$txtemail";
$message="<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2px\"><b>A message has been sent by $txtname ($txtemail). The message is given below:</b></font><br><br><br><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3 px\">";
$message.=$body."</font><br><br><br><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2 px\"><b>"."This is a computer generated mail</b></font><br><br><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1px\">www.mydomain.com</font>";
$mailsent=mail($to, $subject, $message, $headers);
print_r($mailsent);
if($mailsent)
{
$headers = "Content-Type: text/html; charset=iso-8859-1"."\r\n"."From: Bookings <www.mydomain.com>" . "\r\n" .
"Reply-To: info#mydomain.com" . "\r\n"
;
$to=$_POST['txtemail'];
$subject=" HOUSEBOATS!";
$message="Thanks for choosing <b> HOUSEBOATS</b>.";
$mailsent=mail($to, $subject, $message, $headers);
{
//Clear the Body
$body = "Message from www.yourdomain.com<br/><br/>
Thanks for your Message! We will contact you soon.";
{
header("Location:success.html");//Change the address
}
}
}
?>

Try to change the mail part to this. Change your $body into $message and divide into smaller parts for easier control.
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/html; charset=UTF-8";
$headers[] = "From: Bookings www.mydomain.com <myemail#gmail.com>";
$headers[] = "Reply-To: Bookings <myemail#gmail.com>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
$message = "Hello " . $txtname. ",\r\n\n";
$message .= "<table border='0px' bgcolor='#FFFFFF'>";
$message .= "<tr>";
$message .= "<td bgcolor='#dcdcdc' width='150px'>";
$message .= " Name </td>";
$message .= "<td bgcolor='#dcdcdc'> <font face='Arial' size='2px'>";
$message .= "<b> ". $txtname ."</b></font></td>";
$message .= "</tr>";
$message .= "Best regards,\r\n\r\nJohn Doe (bookings\r\n\r\n";
mail($txtemail, '=?utf-8?B?'.base64_encode($subject).'?=', $message, implode("\r\n", $headers));

Related

email sending on php

May mail is working fine but unknown sender error is showing on gmail after sending the mail. My php code is as follows
$sendto="testconcepttc#gmail.com";
$subject = "Payment details of ".$dmail['name'];
$message = "<br><br>";
$message .= '<table border="0" cellspacing="5" cellpadding="4" width="600"style="border-collapse:collapse; font-family:Lucida Sans; border-color:#CCCCCC">
<tr style="background-color:#023564; color:#FFF;">
<td colspan="2"><h3 align="center">Registration Information From Midterm Delhi CSI 2017</h3></td>
</tr>
<tr>
<td width="54%"><p>Name</p></td>
<td width="46%"><p>'.$dmail['name'].'</p></td>
</tr>
<tr>
<td width="54%"><p>Age</p></td>
<td width="46%"><p>'.$dmail['age'].'</p></td>
</tr>
<tr>
<td width="54%"><p>Institution</p></td>
<td width="46%"><p>'.$ucomp.'</p></td>
</tr>
<tr>
<td width="54%"><p>Designation</p></td>
<td width="46%"><p>'.$dmail['designation'].'</p></td>
</tr>
<tr>
<td width="54%"><p>Postal Address</p></td>
<td width="46%"><p>'.$dmail['address'].'</p></td>
</tr>
<tr>
<td width="54%"><p>City</p></td>
<td width="46%"><p>'.$dmail['city'].'</p></td>
</tr>
<tr>
<td width="54%"><p>State</p></td>
<td width="46%"><p>'.$dmail['state'].'</p></td>
</tr>
<tr>
<td width="54%"><p>Pin</p></td>
<td width="46%"><p>'.$dmail['pin'].'</p></td>
</tr>
<tr>
<td width="54%"><p>Country</p></td>
<td width="46%"><p>'.$dmail['country'].'</p></td>
</tr>
<tr>
<td width="54%"><p>Phone (Off).</p></td>
<td width="46%"><p>'.$dmail['phone_off'].'</p></td>
</tr>
<tr>
<td width="54%"><p>Phone (Res).</p></td>
<td width="46%"><p>'.$dmail['phone_res'].'</p></td>
</tr>
<tr>
<td width="54%"><p>Mobile No</p></td>
<td width="46%"><p>'.$dmail['phone'].'</p></td>
</tr>
<tr>
<td width="54%"><p>E-mail</p></td>
<td width="46%"><p>'.$email.'</p></td>
</tr>
<tr>
<td width="54%"><p>Gender</p></td>
<td width="46%"><p>'.$dmail['gender'].'</p></td>
</tr>
<tr>
<td width="54%"><p>Food Preference</p></td>
<td width="46%"><p>'.$dmail['dite'].'</p></td>
</tr>
<tr>
<td width="54%"><p>CSI Number</p></td>
<td width="46%"><p>'.$dmail['ioa_membership_no'].'</p></td>
</tr>
<tr>
<td width="54%"><p>MCI Number</p></td>
<td width="46%"><p>'.$csi.'</p></td>
</tr>
</table>';
$username=$dmail['name'];
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$header .= "From: ".$username."\r\n";
$header .="\r\n";
$retval = mail ($sendto,$subject,$message,$header);
return $retval;
Try to add Reply-To header.
$header .= 'From: from#email.com' . "\r\n";
$header .= 'Reply-To: from#email.com' . "\r\n";
OR with name:
$header .= 'From: "From Name" <from#email.com>' . "\r\n";
$header .= 'Reply-To: "From Name" <from#email.com>' . "\r\n";

PHP Mail not showing HTML in Switch Statement

I have a form with all the submissions going to one person but also sends a copy to another person responsible for the State that the user chose with the switch statement. The notification email that goes the the main admin looks fine (html is generated) but the ones in the switch statement are showing as plain text and show the HTML tags. Any idea how to fix this? Thank you.
//after user registers send notification to admin
$to = 'admin#email.com'
$subject = 'subject';
$message = "<!DOCTYPE html>
<html>
<body>
<div align='left'>
<strong>New Registration Information:</strong><br />
<br />
<table cellspacing=\"4\" cellpadding=\"4\" align=\"left\">
<tr>
<td><strong>Username:</strong></td>
<td>".$userInput."</td>
</tr>
<tr>
<td><strong>Password:</strong></td>
<td>".$passInput."</td>
</tr>
<tr>
<td><strong>Email:</strong></td>
<td>".$emailInput."</td>
</tr>
<tr>
<td><strong>First Name:</strong></td>
<td> ".$fnameInput."</td>
</tr>
<tr>
<td><strong>Middle Name:</strong></td>
<td>".$mnameInput."</td>
</tr>
<tr>
<td><strong>Last Name:</strong></td>
<td>".$lnameInput."</td>
</tr>
<tr>
<td><strong>Job Title:</strong></td>
<td>".$jobtitleInput."</td>
</tr>
<tr>
<td><strong>Company</strong></td>
<td>".$companyInput."</td>
</tr>
<tr>
<td><strong>Address:</strong></td>
<td>".$addressInput."</td>
</tr>
<tr>
<td><strong>City:</strong></td>
<td>".$cityInput."</td>
</tr>
<tr>
<td><strong>State:</strong></td>
<td>".$stateInput."</td>
</tr>
<tr>
<td><strong>Zip:</strong></td>
<td>".$zipInput."</td>
</tr>
<tr>
<td><strong>Phone Number:</strong></td>
<td>".$phoneInput."</td>
</tr>
<tr>
<td><strong>Registered State:</strong></td>
<td>".$registeredstateInput."</td>
</tr>
<tr>
<td><strong>Membership Level:</strong></td><td>";
if($membershipLevel == 1)
$message .= "Level 1 Here</td></tr></table></div></html>";
else if($membershipLevel == 2)
$message .= "Level 2 Here</td></tr></div></html>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
//now send email to State contact
switch($registeredstateInput){
case "AZ":
$to = 'emailaddress1#email.com';
break;
case "AR":
$to = 'emailaddress2#email.com';
break;
case "CA":
$to = 'emailaddress3#email.com';
break;
}
//if that state doesn't have a contact, don't send email
if($to != 'admin#email.com')
{
mail($to, $subject, $message);
}

Receiving email from contact form

I was working on a simple contact form and after submit button is click it redirects to the thank you page which worked perfectly and received the email from the form. Right now, somehow it doesnt send email anymore. I dont know what I did that messed up the code.
PHP
<?php
$toemail = "cluneborg#hotmail.com";
$subject = "New Agent Inquries";
$full_name = $_POST['full_name'];
$email = $_POST['email'];
$agent_type = $_POST['agent_type'];
if($_SERVER['REQUEST_METHOD']=="POST") {
$full_name=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['full_name']));
$email=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['email']));
$agent_type=str_replace ( array("\n"), array(" <br>"),trim($_REQUEST['agent_type']));
$contentmsg=stripslashes("<br><b><font style=color:#CC3300>$subject</font></b><br>
<table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC>
<tr>
<td width=165 align=right valign=top bgcolor=#FFFFFF><B>Full Name: </b> </td>
<td width=565 align=left valign=top bgcolor=#FFFFFF> $full_name</td>
</tr>
<tr>
<td width=165 align=right valign=top bgcolor=#FFFFFF><B>Email Address: </b> </td>
<td width=565 align=left valign=top bgcolor=#FFFFFF> $email</td>
</tr>
<tr>
<td width=165 align=right valign=top bgcolor=#FFFFFF><B>Type of Agent:</b> </td>
<td width=565 align=left valign=top bgcolor=#FFFFFF> $agent_type</td>
</tr>
</table>
");
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= 'To: Mary <mary#example.com>, Eric <eric#example.com>' . "\r\n";
$headers .= 'From: Website' . "\r\n";
if(mail($toemail,$subject,$contentmsg,$headers)){
header("Location: http://www.magnixsolutions.com/clients/tas/thanks.html");
}else{
echo "Mail was not sent!";
}
}
?>

What is wrong with my PHP email code; it won't redirect to thank you page [duplicate]

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 9 years ago.
Curious as to what is wrong with the following php code which sends an email when a contact form is filled out and submitted. The email arrives perfectly but instead of redirecting it gives the following error:
Warning: Cannot modify header information - headers already sent by (output started at /home4/ranchoba/public_html/marvan/marvan/send.php:1) in /home4/ranchoba/public_html/marvan/marvan/send.php on line 112
I've tried calling the php file by the action in the form as well as by placing a in the very first line of the page. Neither one works.
PHP Code:
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
//if the form is submitted, go ahead and send the email to ops
ob_start();
if ($_POST['is_form_submitted'] == "yes")
{
//Send email to ops of this request-----------------------------------------------------------------------------------
// multiple recipients
$to = 'blah#gmail.com';
// subject
$subject = "Contact Request: ".$_POST['name'];
// message
$message = '
<html>
<head>
<title>Re: Marvan Site Contact Request</title>
<style type="text/css">
<!--
.style4 {font-family: Arial, Helvetica, sans-serif; font-size: 12; }
.style5 {font-size: 12}
.style6 {font-family: Arial, Helvetica, sans-serif; font-size: 12; font-weight: bold; }
-->
</style>
</head>
<body>';
$message=$message.'
<table width="450" border="0" align="center" cellpadding="4" cellspacing="0" style="border-color:#CCCCCC; border-style:solid; border-width:1px; background-color:#FFFFFF; padding-top:3px;">
<tr>
<td width="430" style="height:auto;" valign="top">';
$message=$message.'<img src="http://www.blah.com/blah/images/logo.png">';
$message=$message.'<hr>';
$message=$message.'<h2 style="font-family:Arial, Helvetica, sans-serif; color:#B58736">Contact Request </h2>';
$message=$message.'
<table width="486" border="0" align="center" cellpadding="4" cellspacing="2">
<tr>
<td colspan="4" valign="top"><div align="left" class="style4"><span style="color:#000000; font-weight:bold;">Contact Details: </span></div></td>
</tr>
<tr>
<td width="145" valign="top"><div align="left" class="style4">Name :</div></td>
<td width="1" valign="top"><span class="style5"></span></td>
<td width="984" colspan="2" valign="top"><div align="left" class="style6">';
$message = $message. $_POST['name'];
$message = $message.'</div></td>
</tr>
<tr>
<td valign="top"><div align="left" class="style4">Email :</div></td>
<td valign="top"><span class="style5"></span></td>
<td colspan="2" valign="top"><div align="left" class="style6">';
$message = $message. $_POST['email'];
$message = $message.'</div></td>
</tr>
<tr>
<td valign="top"><div align="left" class="style4">Subject :</div></td>
<td valign="top"><span class="style5"></span></td>
<td colspan="2" valign="top"><div align="left" class="style6">';
$message = $message. $_POST['subject'];
$message = $message.'</div></td>
</tr>
<tr>
<td valign="top"><div align="left" class="style4">Phone :</div></td>
<td valign="top"><span class="style5"></span></td>
<td colspan="2" valign="top"><div align="left" class="style6">';
$message = $message. $_POST['phone'];
$message = $message.'</div></td>
</tr>
<tr>
<td valign="top"><div align="left" class="style4">Message :</div></td>
<td valign="top"><span class="style5"></span></td>
<td colspan="2" valign="top"><div align="left" class="style6">';
$message = $message. $_POST['message'];
$message = $message.'</div></td>
</tr>';
$message = $message.'
<tr> <tr><td colspan="4" valign="top"><span class="style5"></span></td>
</tr>';
$message = $message.'
</table>
<br /></td>
</tr>
</table>
<p> </p>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
/* $headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";*/
/* $headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";*/
// Mail it
mail($to, $subject, $message, $headers);
//end of Send Email to Client --------------------------------------------------------------
//redirect to the thank you page
header('Location: http://www.blah.com/blah/thank-you.php');
} //end of if ($_POST['is_form_submitted'] == "yes")
?>
Maybe you have space before <?php tag in your scripts. Check it please and remove them. Also use UTF-8 file encoding without BOM
It is best to find where you are outputting a space or line that is causing the header() to fail. But if you cannot, try this to clear the buffer before header().
if (ob_get_length() > 0 ) {
ob_clean();
flush();
}

Changing php form to submit a styled email (HTML email)

When I submit my form, I receive the email in plain text and not quite in the format I'd like it to be. I'd like it to at least have color to the body and arrange the email so that its neater.
on the contact.php form ... this is what I currently have:
$msg = "You have been contacted by $name with regards to Accommodation.
They passed verification and their message is as follows." . PHP_EOL . PHP_EOL;
$msg .= "$comments" . PHP_EOL . PHP_EOL;
$msg .= "You can contact $name via email, $email or via phone $phone." .
PHP_EOL . PHP_EOL;
$msg .= "We want to stay from the $dayin to the $dayout" . PHP_EOL .
PHP_EOL;
Why is this form using $msg? I've seen in other forms, they use $message.
Can I add CSS styling to the above form?
I also see:
$headers = "From: $email" . PHP_EOL;
$headers .= "Reply-To: $email" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;
Would I need to change "plain" to "HTML"?
Any suggestions or examples would be great!
EDIT:
Ok so now my header are:
$headers = "From: $email" . PHP_EOL;
$headers .= "Reply-To: $email" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . "\r\n" . PHP_EOL;
$headers .= "Content-type: text/html;charset=iso-8859-1" . "\r\n" .
PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;
Do I need PHP_EOL in each header?
My $msg looks like:
$msg = '<style type="text/css">
<!--
.style {
font-family: Arial;
font-size: 12px;
color: #4D241E;
}
body {
background-image: url();
background-color: #F1EAE4;
}
.style1 {font-size: 14px}
-->
</style>
<p> </p>
<table width="420" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td><table width="100%" border="0" cellpadding="8" cellspacing="0" bgcolor="#E7D3AF"
class="style">
<tr>
<td colspan="2" valign="top"><div align="center"><strong><span
class="style1">Submission / Enquiry from your website</span><br>
........................................................................
</strong><br>
</div></td>
</tr>
<tr>
<td width="32%" valign="top"><div align="left"><strong>Date Submitted</strong>
</div></td>
<td width="68%" valign="top">'. date("F j, Y, g:i a") .'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Name</strong></div></td>
<td valign="top">'.$_POST['name'].'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Email</strong></div></td>
<td valign="top">'.$_POST['email'].'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Phone</strong></div></td>
<td valign="top">'.$_POST['phone'].'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Day in</strong></div></td>
<td valign="top">'.$_POST['dayin'].'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Day out</strong></div></td>
<td valign="top">'.$_POST['dayout'].'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Comments</strong></div></td>
<td valign="top">'.$_POST['comments'].'</td>
</tr>
</table></td>
</tr>
</table>
';
EDIT:
MY NEW HTML EMAIL DESIGN:
<table width="600" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="12" height="14"></td>
<td width="140"></td>
<td width="432"></td>
<td width="16"></td>
</tr>
<tr>
<td height="71"></td>
<td colspan="2" align="center" valign="middle" bgcolor="#F5F5F5"><span style="font-
family:Arial; font-size:18px; color:#333333;"><strong>Submission from</strong>
</span><br />
<span style="font-family:Arial; font-size:16px; color:#f9930f;">
<em>Your website</em></span></td>
<td></td>
</tr>
<tr>
<td height="16"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="30"></td>
<td valign="middle"><span style="font-family:Arial; font-size:12px; color:#333333;">
<strong>Name:</strong></span></td>
<td valign="middle"><span style="font-family:Arial; font-size:12px;
color:#333333;">'.$_POST['name'].'</span></td>
<td></td>
</tr>
<tr>
<td height="30"></td>
<td valign="middle"><span style="font-family:Arial; font-size:12px; color:#333333;">
<strong>Email:</strong></span></td>
<td valign="middle"><span style="font-family:Arial; font-size:12px;
color:#333333;">'.$_POST['email'].'</span></td>
<td></td>
</tr>
<tr>
<td height="30"></td>
<td valign="middle"><span style="font-family:Arial; font-size:12px; color:#333333;">
<strong>Phone:</strong></span></td>
<td valign="middle"><span style="font-family:Arial; font-size:12px;
color:#333333;">'.$_POST['phone'].'</span></td>
<td></td>
</tr>
<tr>
<td height="30"></td>
<td valign="middle"><span style="font-family:Arial; font-size:12px; color:#333333;">
<strong>Day in:</strong></span></td>
<td valign="middle"><span style="font-family:Arial; font-size:12px;
color:#333333;">'.$_POST['dayin'].'</span></td>
<td></td>
</tr>
<tr>
<td height="30"></td>
<td valign="middle"><span style="font-family:Arial; font-size:12px; color:#333333;">
<strong>Day out:</strong></span></td>
<td valign="middle"><span style="font-family:Arial; font-size:12px;
color:#333333;">'.$_POST['dayout'].'</span></td>
<td></td>
</tr>
<tr>
<td height="30"></td>
<td valign="middle"><span style="font-family:Arial; font-size:12px; color:#333333;">
<strong>Comments:</strong></span></td>
<td> </td>
<td></td>
</tr>
<tr>
<td height="190"></td>
<td colspan="2" valign="top"><span style="font-family:Arial; font-size:12px;
color:#333333;">'.$_POST['comments'].'</span></td>
<td></td>
</tr>
<tr>
<td height="20"></td>
<td> </td>
<td> </td>
<td></td>
</tr>
</table>
Now when I add this form in my php and submit my form ... I receive my submission that doesn't look like the table layout like above.
You can use the following headers. These will allow you to just put normal HTML in your message.
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= 'From: <example#example.com>' . "\r\n";
$headers .= 'Cc: example two#example.com' . "\r\n";
Yep you are going to have to use
Content-type:text/html;charset=iso-8859-1\r\n
It might be a good idea to provide your email in both HTML and text formats as not all email applications support HTML, and many others support it poorly.
To do so use this header instead. The boundary thing is what separates the HTML and text versions in the email, the line below generates a unique code which is suitable for this purpose
$boundary = md5(date('r', time()));
$headers .= "\r\nContent-Type: multipart/alternative; boundary=$boundary."\"";
Before the text version of the email post this code, note the "--" at the begging. You use the same boundary throughout the email.
--<?php echo $boundary; ?>
Before the HTML version post the same code again
There is a good template you can use here
http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php

Categories