[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1900
  • Last Modified:

How to format php email

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
isaacr25
Asked:
isaacr25
  • 2
2 Solutions
 
Loganathan NatarajanLAMP DeveloperCommented:
0
 
Loganathan NatarajanLAMP DeveloperCommented:
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now