Solved

How to format php email

Posted on 2008-06-11
2
1,884 Views
Last Modified: 2011-03-22
I need some guidance in formatting a php email. I would like the email to be formatted (tables, line breaks etc) when it is sent. How do I do this? Please see my php script attached (sorry for the length). Thanks in advance.
<?php
 
 
// get posted data into local variables
$EmailFrom = "website@domainhere.com";
$EmailTo = "emailhere@hotmail.com";
$Subject = "Message from Website";
$name = Trim(stripslashes($_POST['name'])); 
$phone1 = Trim(stripslashes($_POST['phone1'])); 
$email = Trim(stripslashes($_POST['email'])); 
$position = Trim(stripslashes($_POST['position'])); 
$learn = Trim(stripslashes($_POST['learn'])); 
$date = Trim(stripslashes($_POST['date'])); 
$address = Trim(stripslashes($_POST['address'])); 
$city = Trim(stripslashes($_POST['city'])); 
$state = Trim(stripslashes($_POST['state'])); 
$zip = Trim(stripslashes($_POST['zip'])); 
$phone2 = Trim(stripslashes($_POST['phone2'])); 
$phone3 = Trim(stripslashes($_POST['phone3'])); 
$workdate = Trim(stripslashes($_POST['workdate'])); 
$wage = Trim(stripslashes($_POST['wage'])); 
$school1 = Trim(stripslashes($_POST['school1'])); 
$school2 = Trim(stripslashes($_POST['school2']));
$school3 = Trim(stripslashes($_POST['school3']));
$school4 = Trim(stripslashes($_POST['school4']));
$location1 = Trim(stripslashes($_POST['location1'])); 
$location2 = Trim(stripslashes($_POST['location2']));
$location3 = Trim(stripslashes($_POST['location3']));
$location4 = Trim(stripslashes($_POST['location4']));
$years1 = Trim(stripslashes($_POST['years1'])); 
$years2 = Trim(stripslashes($_POST['years2']));
$years3 = Trim(stripslashes($_POST['years3']));
$years4 = Trim(stripslashes($_POST['years4']));
$degree1 = Trim(stripslashes($_POST['degree1'])); 
$degree2 = Trim(stripslashes($_POST['degree2']));
$degree3 = Trim(stripslashes($_POST['degree3']));
$degree4 = Trim(stripslashes($_POST['degree4']));
$major1 = Trim(stripslashes($_POST['major1'])); 
$major2 = Trim(stripslashes($_POST['major2']));
$major3 = Trim(stripslashes($_POST['major3']));
$major4 = Trim(stripslashes($_POST['major4']));
$employer1 = Trim(stripslashes($_POST['employer1'])); 
$employer2 = Trim(stripslashes($_POST['employer2']));
$employer3 = Trim(stripslashes($_POST['employer3']));
$jobtitle1 = Trim(stripslashes($_POST['jobtitle1'])); 
$jobtitle2 = Trim(stripslashes($_POST['jobtitle2']));
$jobtitle3 = Trim(stripslashes($_POST['jobtitle3']));
$employedfrom1 = Trim(stripslashes($_POST['employedfrom1'])); 
$employedfrom2 = Trim(stripslashes($_POST['employedfrom2']));
$employedfrom3 = Trim(stripslashes($_POST['employedfrom3']));
$employedto1 = Trim(stripslashes($_POST['employedto1'])); 
$employedto2 = Trim(stripslashes($_POST['employedto2']));
$employedto3 = Trim(stripslashes($_POST['employedto3']));
$empaddress1 = Trim(stripslashes($_POST['empaddress1'])); 
$empaddress2 = Trim(stripslashes($_POST['empaddress2']));
$empaddress3 = Trim(stripslashes($_POST['empaddress3']));
$empcity1 = Trim(stripslashes($_POST['empcity1'])); 
$empcity2 = Trim(stripslashes($_POST['empcity2']));
$empcity3 = Trim(stripslashes($_POST['empcity3']));
$empstate1 = Trim(stripslashes($_POST['empstate1'])); 
$empstate2 = Trim(stripslashes($_POST['empstate2']));
$empstate3 = Trim(stripslashes($_POST['empstate3']));
$empzip1 = Trim(stripslashes($_POST['empzip1'])); 
$empzip2 = Trim(stripslashes($_POST['empzip2']));
$empzip3 = Trim(stripslashes($_POST['empzip3']));
$empphone1 = Trim(stripslashes($_POST['empphone1'])); 
$empphone2 = Trim(stripslashes($_POST['empphone2']));
$empphone3 = Trim(stripslashes($_POST['empphone3']));
$empsuper1 = Trim(stripslashes($_POST['empsuper1'])); 
$empsuper2 = Trim(stripslashes($_POST['empsuper2']));
$empsuper3 = Trim(stripslashes($_POST['empsuper3']));
$empstart1 = Trim(stripslashes($_POST['empstart1'])); 
$empstart2 = Trim(stripslashes($_POST['empstart2']));
$empstart3 = Trim(stripslashes($_POST['empstart3']));
$empend1 = Trim(stripslashes($_POST['empend1'])); 
$empend2 = Trim(stripslashes($_POST['empend2']));
$empend3 = Trim(stripslashes($_POST['empend3']));
$empcontact1 = Trim(stripslashes($_POST['empcontact1'])); 
$empcontact2 = Trim(stripslashes($_POST['empcontact2']));
$empcontact3 = Trim(stripslashes($_POST['empcontact3']));
$empduties1 = Trim(stripslashes($_POST['empduties1'])); 
$empduties2 = Trim(stripslashes($_POST['empduties2']));
$empduties3 = Trim(stripslashes($_POST['empduties3']));
$empreasons1 = Trim(stripslashes($_POST['empreasons1'])); 
$empreasons2 = Trim(stripslashes($_POST['empreasons2']));
$empreasons3 = Trim(stripslashes($_POST['empreasons3']));
 
 
// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}
 
// prepare email body text
$Body = "";
$Body .= "Date: ";
$Body .= $date;
$Body .= "\n";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Home Phone: ";
$Body .= $phone1;
$Body .= "\n";
$Body .= "Office Phone: ";
$Body .= $phone2;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $address;
$Body .= "\n";
$Body .= "City: ";
$Body .= $city;
$Body .= "\n";
$Body .= "State: ";
$Body .= $state;
$Body .= "\n";
$Body .= "Zip: ";
$Body .= $zip;
$Body .= "\n";
$Body .= "Position: ";
$Body .= $position;
$Body .= "\n";
$Body .= "How did you learn about the position?: ";
$Body .= $learn;
$Body .= "\n";
$Body .= "On what date will you be available for work?: ";
$Body .= $workdate;
$Body .= "\n";
$Body .= "Desired wage/salary: ";
$Body .= $wage;
$Body .= "\n";
 
// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
 
// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=appsent.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

Open in new window

0
Comment
Question by:isaacr25
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 500 total points
ID: 21766746
0
 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 500 total points
ID: 21766763
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question