email sending on php - 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";

Related

file_get_contents in php is not returning E-mail id, why?

Actually I am sending email from php. When I am using file_get_contents() for email body from external file, its not returning email id. Instead email id it's returning '[email protected]'.
Here is my code to call the file with file_get_contents():
$params = 'for=team&name='.urlencode($name).'&email='.urlencode($email).'&phone='.urlencode($phone).'&company='.urlencode($company).'&looking_for='.$looking_for.'&country='.urlencode($country).'&source_page='.urlencode($source_page);
$team_msg = file_get_contents(get_template_directory_uri().'/mail-template/contact_us_email_temp.php?'.$params);
$headers[] = "MIME-Version: 1.0" . "\r\n";
$headers[] .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers[] .= 'From: Someone <someone#domainname.com>';
$to = 'myselft#domainname.com';
$team_subject = 'email subject';
wp_mail($to, $team_subject, $team_msg, $headers );
And Here is the 'contact_us_email_temp.php' which is called from function:
$message = "<table border='0'><tbody>
<tr><td colspan='2'>Users Detail:</td></tr>
<tr>
<td><b>Name</b></td>
<td>".$_GET['name']."</td>
</tr>
<tr>
<td><b>Official Email</b></td>
<td>".$_GET['email']."</td>
</tr>
<tr>
<td><b>Company</b></td>
<td>".$_GET['company']."</td>
</tr>
<tr>
<td><b>Mobile Number</b></td>
<td>".$_GET['phone']."</td>
</tr>
<tr>
<td><b>Looking For</b></td>
<td>".$_GET['looking_for']."</td>
</tr>
<tr>
<td><b>Country</b></td>
<td>".$_GET['country']."</td>
</tr>
<tr>
<td><b>Source Page</b></td>
<td>".$_GET['source_page']."</td></tr>
<tr>
</tbody>
</table>";
echo $message;
I am not sure what's wrong with the function.
Thanks
file_get_contents() doesn't work like a HTTP Request. You're loading a the ACTUAL file as a string and any code isn't executed. So when you send the mail now, the viewer will see the $_GET['name'] for example. What you want to do is create a function out of the contact_us_email_temp.php file and use the GET parameters as function parameters.
function getEmail($name, $email, $company, $phone, $looking_for, $country, $source_page) {
$message = "
<table border='0'><tbody>
<tr><td colspan='2'>Users Detail:</td></tr>
<tr>
<td><b>Name</b></td>
<td>".$name."</td>
</tr>
<tr>
<td><b>Official Email</b></td>
<td>".$email."</td>
</tr>
<tr>
<td><b>Company</b></td>
<td>".$company."</td>
</tr>
<tr>
<td><b>Mobile Number</b></td>
<td>".$phone."</td>
</tr>
<tr>
<td><b>Looking For</b></td>
<td>".$looking_for."</td>
</tr>
<tr>
<td><b>Country</b></td>
<td>".$country."</td>
</tr>
<tr>
<td><b>Source Page</b></td>
<td>".$source_page."</td></tr>
<tr>
</tbody>
</table>";
return $message;
}
Require this script in your main script and run the function instead of file_get_contents

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!";
}
}
?>

Copy HTML form in email PHP

I am trying to copy my HTML form in email body. Below is code where the form is already in php file but I want if the user submits html form file then all the form data between that is not hidden is copied (as disabled elements) in the body of the email. Also if there is any file attachment field, it should be attached to the email.
<?php
// multiple recipients
$to = 'demo#localhost.com' . ', '; // note the comma
$to .= 'demo#localhost.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body style="padding:3px; margin:0px;" bgcolor="#FFFFFF">
<table cellpadding="0" cellspacing="0" border="0" width="440">
<tr><td style="height:10px"></td></tr>
<tr>
<td colspan="2" style="text-align:justify; line-height:15px;" class="body">
<form name="frm" method="POST" action="careersuccess.php" enctype="multipart/form-data">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="23%" class="body"> Name</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strname" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Address</td>
<td width="3%" class="body">:</td>
<td width="74%"><textarea cols="16" name="straddress"></textarea></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> City</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strcity" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> State</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strstate" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Contact No</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strno" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Email</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="stremail" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Comments</td>
<td width="3%" class="body">:</td>
<td width="74%"><textarea cols="16" name="strcomments"></textarea></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Resume</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="file" name="strresume"></td>
</tr>
<tr><td style="height:10px"></td></tr>
<tr>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
</table>
</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 .= 'From: Birthday Reminder <birthday#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);
?>
I'll assume the form is submitted from a website, and that you're not trying to create a submittable form in an email. To copy the data submitted in the form, $_POST[""]; would surely be the best way to obtain the data. Obviously the data wouldn't be manipulatable once the email has arrived in the recipient's inbox but, as I say, I'm assuming you're not trying to create a form which can be submitted from an email.
Your form on the website was fine:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body style="padding:3px; margin:0px;" bgcolor="#FFFFFF">
<table cellpadding="0" cellspacing="0" border="0" width="440">
<tr><td style="height:10px"></td></tr>
<tr>
<td colspan="2" style="text-align:justify; line-height:15px;" class="body">
<form name="frm" method="POST" action="careersuccess.php" enctype="multipart/form-data">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="23%" class="body"> Name</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strname" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Address</td>
<td width="3%" class="body">:</td>
<td width="74%"><textarea cols="16" name="straddress"></textarea></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> City</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strcity" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> State</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strstate" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Contact No</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strno" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Email</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="stremail" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Comments</td>
<td width="3%" class="body">:</td>
<td width="74%"><textarea cols="16" name="strcomments"></textarea></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Resume</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="file" name="strresume"></td>
</tr>
<tr><td style="height:10px"></td></tr>
<tr>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
</table>
</body>
</html>
Your file careersuccess.php would then need to include something like:
<?php
// multiple recipients
$to = 'demo#localhost.com' . ', '; // note the comma
$to .= 'demo#localhost.com';
// subject
$subject = 'Birthday Reminders for August';
$strName = $_POST["strname"]; //assigns strname from form to PHP variable
$strAddress = $_POST["straddress"];
$strCity = $_POST["strcity"];
$strState = $_POST["strstate"];
$strNumber = $_POST["strnumber"];
$strEmail = $_POST["stremail"];
$strComments = $_POST["strcomments"];
$strResume = $_POST["strresume"];
$lineBreak = "<br />\n\"; //adds carriage return to break up your message
$message = "Name: ".$strName.$lineBreak."Address: ".$strAddress.$lineBreak."City: ".$strCity.$lineBreak."State: ".$strState.$lineBreak...for the rest of your variables;
// 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 .= 'From: Birthday Reminder <birthday#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);
?>
That will result in the submitted values of the form being copied in to the email in the $message variable for the mail() function.

couldnot modify header information [duplicate]

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 9 years ago.
I got an "Warning: Cannot modify header information - headers already sent (output started at process_contact.php:5) in (/process_contact.php on line 147 )" while using mail() in php for sending an mail to multiple user.
$from = "test#gmail.com";
$adminmessage="You have received an email from ".$_POST['email'].
$to = "test1#gmail.com";
$subject = "Email Received for an Order";
$message = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body>
Online Reservation Form has been submitted on the website on '.$date.'.<br><br>
<table width="710px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="40%" height="30" valign="top">Name:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["name"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Address:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["address"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Phone no.:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["phone"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">E-mail:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["email"].'</b></td>
</tr>
<tr>
<tr>
<td width="40%" height="30" valign="top">Check Out:</td>
<td width="60%" height="30" valign="top"><b>'. $_POST["price"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Night:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["night"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Rooms:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["rooms"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Adults:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["adults"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Children:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["children"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Room Type:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["roomtype"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Price:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["price"].'</b></td>
</tr>
<tr>
<p><strong>Payment Details</strong></p>
</tr>
<tr>
<td width="40%" height="30" valign="top">Payment Type:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["paymentype"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Card Name Holder:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["cardholder"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Credit Card no.:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["creditcardno"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Expiration Date:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["exp"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Security Code:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["securitycode"].'</b></td>
</tr>
<tr>
<p>Payment Details</strong></p>
</tr>
<tr>
<td width="40%" height="30" valign="top">Billing Address( Street adress ):</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["billing1"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Billing Address( City/State/Zip ):</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["billing2"].'</b></td>
</tr>
<tr>
<td width="40%" height="30" valign="top">Special Request:</td>
<td width="60%" height="30" valign="top"><b>'.$_POST["comments"].'</b></td>
</tr>
</table>
</body></html>';
$headers = "From:" . $from."\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
ini_set("SMTP","192.168.0.30");
$date = date("m/d/Y H:i:s");
mail($to,$subject,$message,$headers);
//for client
$from="test#gmail.com";
$to1=$_POST['email'];
$subject1="Confirmation";
$clentmessage1 ='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body><p>Dear Customer! '.$_POST["name"].'.Your reservation has been confirmed.<br>
Thank you for Emailing us. We will get back to you shortly.<br/>
Plz donot hesitate to contact us atfor further information or any queries!<br/><br/><br/>
<strong>Super Value Inn</strong>
</body>
</html>';
$headers = "From:" . $from."\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
ini_set("SMTP","192.168.0.30");
mail($to1,$subject1,$clentmessage1,$headers);
echo "Mail Sent.";
header('Location: reservation.php?sentok');
exit();
}
else
{
header('Location: reservation.php?err');
}
You cannot send header information after you have already echoed something. See PHP output buffering for information on how to get around this.
Drop this and it should work:
echo "Mail Sent.";
echo "Mail Sent.";
header('Location: reservation.php?sentok');
That ^
In any case, it doesn't make sense anyway to echo something then directly redirect. You could instead output Mail Sent at reservation.php
if(isset($_GET['sentok'])) echo 'Mail Sent.';
EDIT:
I think you got a syntax error there as pointed by your error message:
$adminmessage="You have received an email from ".$_POST['email']. // <-- this
$to = "test1#gmail.com";
This gives me an Undefined Variable notice in my local setup, which in turns stopping you from calling header() as that notice is counted as an output by php.
You have an echo statement before the header() call, that will cause headers to be sent. You must not output anything before a header()

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