Solved

How to format php email

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now