Solved

How to format php email

Posted on 2008-06-11
2
1,883 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

732 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