Solved

How to format php email

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
regex expression 9 23
using hash in login 34 20
Adding through query php 9 12
Asp.net mvc foreach 3 12
Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

746 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

13 Experts available now in Live!

Get 1:1 Help Now