PHP Mail not showing HTML in Switch Statement - php

I have a form with all the submissions going to one person but also sends a copy to another person responsible for the State that the user chose with the switch statement. The notification email that goes the the main admin looks fine (html is generated) but the ones in the switch statement are showing as plain text and show the HTML tags. Any idea how to fix this? Thank you.
//after user registers send notification to admin
$to = 'admin#email.com'
$subject = 'subject';
$message = "<!DOCTYPE html>
<html>
<body>
<div align='left'>
<strong>New Registration Information:</strong><br />
<br />
<table cellspacing=\"4\" cellpadding=\"4\" align=\"left\">
<tr>
<td><strong>Username:</strong></td>
<td>".$userInput."</td>
</tr>
<tr>
<td><strong>Password:</strong></td>
<td>".$passInput."</td>
</tr>
<tr>
<td><strong>Email:</strong></td>
<td>".$emailInput."</td>
</tr>
<tr>
<td><strong>First Name:</strong></td>
<td> ".$fnameInput."</td>
</tr>
<tr>
<td><strong>Middle Name:</strong></td>
<td>".$mnameInput."</td>
</tr>
<tr>
<td><strong>Last Name:</strong></td>
<td>".$lnameInput."</td>
</tr>
<tr>
<td><strong>Job Title:</strong></td>
<td>".$jobtitleInput."</td>
</tr>
<tr>
<td><strong>Company</strong></td>
<td>".$companyInput."</td>
</tr>
<tr>
<td><strong>Address:</strong></td>
<td>".$addressInput."</td>
</tr>
<tr>
<td><strong>City:</strong></td>
<td>".$cityInput."</td>
</tr>
<tr>
<td><strong>State:</strong></td>
<td>".$stateInput."</td>
</tr>
<tr>
<td><strong>Zip:</strong></td>
<td>".$zipInput."</td>
</tr>
<tr>
<td><strong>Phone Number:</strong></td>
<td>".$phoneInput."</td>
</tr>
<tr>
<td><strong>Registered State:</strong></td>
<td>".$registeredstateInput."</td>
</tr>
<tr>
<td><strong>Membership Level:</strong></td><td>";
if($membershipLevel == 1)
$message .= "Level 1 Here</td></tr></table></div></html>";
else if($membershipLevel == 2)
$message .= "Level 2 Here</td></tr></div></html>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
//now send email to State contact
switch($registeredstateInput){
case "AZ":
$to = 'emailaddress1#email.com';
break;
case "AR":
$to = 'emailaddress2#email.com';
break;
case "CA":
$to = 'emailaddress3#email.com';
break;
}
//if that state doesn't have a contact, don't send email
if($to != 'admin#email.com')
{
mail($to, $subject, $message);
}

Related

file_get_contents in php is not returning E-mail id, why?

Actually I am sending email from php. When I am using file_get_contents() for email body from external file, its not returning email id. Instead email id it's returning '[email protected]'.
Here is my code to call the file with file_get_contents():
$params = 'for=team&name='.urlencode($name).'&email='.urlencode($email).'&phone='.urlencode($phone).'&company='.urlencode($company).'&looking_for='.$looking_for.'&country='.urlencode($country).'&source_page='.urlencode($source_page);
$team_msg = file_get_contents(get_template_directory_uri().'/mail-template/contact_us_email_temp.php?'.$params);
$headers[] = "MIME-Version: 1.0" . "\r\n";
$headers[] .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers[] .= 'From: Someone <someone#domainname.com>';
$to = 'myselft#domainname.com';
$team_subject = 'email subject';
wp_mail($to, $team_subject, $team_msg, $headers );
And Here is the 'contact_us_email_temp.php' which is called from function:
$message = "<table border='0'><tbody>
<tr><td colspan='2'>Users Detail:</td></tr>
<tr>
<td><b>Name</b></td>
<td>".$_GET['name']."</td>
</tr>
<tr>
<td><b>Official Email</b></td>
<td>".$_GET['email']."</td>
</tr>
<tr>
<td><b>Company</b></td>
<td>".$_GET['company']."</td>
</tr>
<tr>
<td><b>Mobile Number</b></td>
<td>".$_GET['phone']."</td>
</tr>
<tr>
<td><b>Looking For</b></td>
<td>".$_GET['looking_for']."</td>
</tr>
<tr>
<td><b>Country</b></td>
<td>".$_GET['country']."</td>
</tr>
<tr>
<td><b>Source Page</b></td>
<td>".$_GET['source_page']."</td></tr>
<tr>
</tbody>
</table>";
echo $message;
I am not sure what's wrong with the function.
Thanks
file_get_contents() doesn't work like a HTTP Request. You're loading a the ACTUAL file as a string and any code isn't executed. So when you send the mail now, the viewer will see the $_GET['name'] for example. What you want to do is create a function out of the contact_us_email_temp.php file and use the GET parameters as function parameters.
function getEmail($name, $email, $company, $phone, $looking_for, $country, $source_page) {
$message = "
<table border='0'><tbody>
<tr><td colspan='2'>Users Detail:</td></tr>
<tr>
<td><b>Name</b></td>
<td>".$name."</td>
</tr>
<tr>
<td><b>Official Email</b></td>
<td>".$email."</td>
</tr>
<tr>
<td><b>Company</b></td>
<td>".$company."</td>
</tr>
<tr>
<td><b>Mobile Number</b></td>
<td>".$phone."</td>
</tr>
<tr>
<td><b>Looking For</b></td>
<td>".$looking_for."</td>
</tr>
<tr>
<td><b>Country</b></td>
<td>".$country."</td>
</tr>
<tr>
<td><b>Source Page</b></td>
<td>".$source_page."</td></tr>
<tr>
</tbody>
</table>";
return $message;
}
Require this script in your main script and run the function instead of file_get_contents

Receiving email from contact form

I was working on a simple contact form and after submit button is click it redirects to the thank you page which worked perfectly and received the email from the form. Right now, somehow it doesnt send email anymore. I dont know what I did that messed up the code.
PHP
<?php
$toemail = "cluneborg#hotmail.com";
$subject = "New Agent Inquries";
$full_name = $_POST['full_name'];
$email = $_POST['email'];
$agent_type = $_POST['agent_type'];
if($_SERVER['REQUEST_METHOD']=="POST") {
$full_name=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['full_name']));
$email=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['email']));
$agent_type=str_replace ( array("\n"), array(" <br>"),trim($_REQUEST['agent_type']));
$contentmsg=stripslashes("<br><b><font style=color:#CC3300>$subject</font></b><br>
<table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC>
<tr>
<td width=165 align=right valign=top bgcolor=#FFFFFF><B>Full Name: </b> </td>
<td width=565 align=left valign=top bgcolor=#FFFFFF> $full_name</td>
</tr>
<tr>
<td width=165 align=right valign=top bgcolor=#FFFFFF><B>Email Address: </b> </td>
<td width=565 align=left valign=top bgcolor=#FFFFFF> $email</td>
</tr>
<tr>
<td width=165 align=right valign=top bgcolor=#FFFFFF><B>Type of Agent:</b> </td>
<td width=565 align=left valign=top bgcolor=#FFFFFF> $agent_type</td>
</tr>
</table>
");
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= 'To: Mary <mary#example.com>, Eric <eric#example.com>' . "\r\n";
$headers .= 'From: Website' . "\r\n";
if(mail($toemail,$subject,$contentmsg,$headers)){
header("Location: http://www.magnixsolutions.com/clients/tas/thanks.html");
}else{
echo "Mail was not sent!";
}
}
?>

PHP MAILER, HOW TO INSERT HTML TABLE

I have PHP mailer script and I am trying to add HTML table into it but when I do the script stops working.
Here's the PHP mailer script
<?php
// Insert your email/web addresses and correct paths
$mailto = 'adil#*******.co.uk' ;
$from = "web#city.com" ;
$subject = "Query from ******* 2012";
$headers = "From: ******* Website";
$formurl = "http://*******.co.uk/citycoaches3/formmail.php" ;
$errorurl = "http://*******.co.uk/citycoaches3/error.php" ;
$thankyouurl = "http://*******.co.uk/citycoaches3/thankyou.php" ;
// Place Your Form info here...
$pickuppoint = ($_POST['pickuppoint']);
$destination = ($_POST['destination']);
// Check If Empty
// Add more Validation/Cleaning here...
// Place your Corresponding info here...
$message =
"Pick Point: $pickuppoint\n\n" .
"Destination: $destination\n\n" .
"noppl: $noppl\n\n"
;
// Leave Alone
mail($mailto, $from, $message);
header( "Location: $thankyouurl" );
exit ;
?>
Any help on this will be appreciated.
Heres what i tried
<?php
$fromAddr = 'adil#********.co.uk'; // the address to show in From field.
$recipientAddr = 'quotes#********.co.uk';
$subjectStr = '[Quick] Query From ********';
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$forward = 1;
$formurl = "http://www.********.co.uk/formmail.php" ;
$errorurl = "http://www.********.co.uk/error.php" ;
$thankyouurl = "http://www.********.co.uk/thankyou.php" ;
header("location:thankyou.php");
$mailBodyText = <<<HHHHHHHHHHHHHH
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Thank You</title>
</head>
<body>
<img src="http://********.co.uk/images/mailsig.png" /> \n\n<br />
<span style="color:#900; font-size:18px;">Below is the result submitted from <strong>[Quick Quote] ******** Website</strong>. It was submitted on <strong>$date at $time</strong>.\n\n</span>
<p><table width="600" border="1" cellpadding="5px">
<tr>
<td><b>Pickup Date:</b> </td>
<td>{$_POST['date']}<br></td>
</tr>
<tr>
<td><b>Pickup Time:</b> </td>
<td>{$_POST['PickupTime-Hours']}:{$_POST['PickupTime-Mins']}<br></td>
</tr>
<tr>
<td><b>Pickup Point:</b> </td>
<td>{$_POST['PickUp-Point']}<br></td>
</tr>
<tr>
<td><b>Destination:</b> </td>
<td>{$_POST['Destination']}<br></td></tr>
<tr>
<td><b>No. Of People:</b> </td>
<td>{$_POST['No-of-Persons']}<br></td>
</tr>
<tr>
<td><b>Journey Type:</b> </td>
<td>{$_POST['JourneyType']}<br></td>
</tr>
<tr>
<tr>
<td><b>Return Date:</b> </td>
<td>{$_POST['returnDate']}<br></td>
</tr>
<tr>
<td><b>Return Time:</b> </td>
<td>{$_POST['returnTime-Hours']}{$_POST['returnTime-Mins']}<br></td>
</tr>
<tr>
<tr>
<td><b>Vehicle Type:</b> </td>
<td>{$_POST['type']}<br></td>
</tr>
<tr>
<tr>
<td><b>Full Name:</b> </td>
<td>{$_POST['Full-Name']}<br></td>
</tr>
<tr>
<tr>
<td><b>Tel / Mobile:</b> </td>
<td>{$_POST['Tel-Mobile']}<br></td>
</tr>
<tr>
<td><b>Email:</b> </td>
<td>{$_POST['Email']}<br></td>
</tr>
<tr>
</table>
</p>
</body>
</html>
HHHHHHHHHHHHHH;
$headers= <<<TTTTTTTTTTTT
From: $fromAddr
MIME-Version: 1.0
Content-Type: text/html;
TTTTTTTTTTTT;
mail($mailto, $from, $message,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep );
header( "Location: $thankyouurl" );
exit ;
?>
Still doesn't work for some reason.
Heres the UPDATE:
After removing
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" .
I managed to receive the email, but it pasted the whole code which is in $message.
Try getting the HTML from a file :
$message = file_get_contents('./path/email.html') // it's easyer to maintain but not mandatory
And add a html content type header
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
then
mail($mailto, $from, $message, $headers) //notice the headers;
As I think the others answers didn't gave you the correct direction yet, here's my addition:
$name = _("test"); // Or insert variable
$message = <<<EOF
// html here
<p>hello $name</p>
EOF;
$to = "";
$subject = "";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: Example <info#example.com>' . "\r\n";
// Mail it
mail($to, $subject, $email, $headers);
You'll need the html headers when sending the email..
ALL thank you very much for your help and suggestions.
I finally got it working here is what I did.
In $message in inserted:
$message = "<html><body>
<b><FONT COLOR='#900' SIZE='13px'>Hi this is working now</FONT></b>
<table width='400' border='0' cellpadding='5px'>
<tr>
<td><b><FONT COLOR='#900'>Pickup Date:</FONT></b> </td>
<td>{$_POST['date']}<br></td>
</tr>
</table>
</html></body>";
And added following headers
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
All working thanks everyone again!
Use php html email and insert table in email body part
If you want to display the messagebody in your message to your recipient, maybe you should try putting a quotation mark in your code:
$mailBodyText = "<<<HHHHHHHHHHHHHH
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Thank You</title>
</head>
<body>
<img src="http://********.co.uk/images/mailsig.png" /> \n\n<br />
<span style="color:#900; font-size:18px;">Below is the result submitted from <strong> [Quick Quote] ******** Website</strong>. It was submitted on <strong>$date at $time</strong>.\n\n</span>
<p><table width="600" border="1" cellpadding="5px">
<tr>
<td><b>Pickup Date:</b> </td>
<td>{$_POST['date']}<br></td>
</tr>
<tr>
<td><b>Pickup Time:</b> </td>
<td>{$_POST['PickupTime-Hours']}:{$_POST['PickupTime-Mins']}<br></td>
</tr>
<tr>
<td><b>Pickup Point:</b> </td>
<td>{$_POST['PickUp-Point']}<br></td>
</tr>
<tr>
<td><b>Destination:</b> </td>
<td>{$_POST['Destination']}<br></td></tr>
<tr>
<td><b>No. Of People:</b> </td>
<td>{$_POST['No-of-Persons']}<br></td>
</tr>
<tr>
<td><b>Journey Type:</b> </td>
<td>{$_POST['JourneyType']}<br></td>
</tr>
<tr>
<tr>
<td><b>Return Date:</b> </td>
<td>{$_POST['returnDate']}<br></td>
</tr>
<tr>
<td><b>Return Time:</b> </td>
<td>{$_POST['returnTime-Hours']}{$_POST['returnTime-Mins']}<br></td>
</tr>
<tr>
<tr>
<td><b>Vehicle Type:</b> </td>
<td>{$_POST['type']}<br></td>
</tr>
<tr>
<tr>
<td><b>Full Name:</b> </td>
<td>{$_POST['Full-Name']}<br></td>
</tr>
<tr>
<tr>
<td><b>Tel / Mobile:</b> </td>
<td>{$_POST['Tel-Mobile']}<br></td>
</tr>
<tr>
<td><b>Email:</b> </td>
<td>{$_POST['Email']}<br></td>
</tr>
<tr>
</table>";

Mail() php is sending the code direct in the mail [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Php mail: how to send html?
I got my mail() with php working my emailmessage =
$email_bericht .= "
<table border='0' width='40%'>
<tr>
<td>Bedrijfsnaam</td>
<td>
".$naam."
</td>
</tr>
<tr>
<td>Risicoadres</td>
<td>
".$risicoadres."
</td>
</tr>
<tr>
<td>Adres</td>
<td>
".$adres."
</td>
</tr>
<tr>
<td>Woonplaats</td>
<td>
".$woonplaats."
</td>
</tr>
<tr>
<td>Relatienummer</td>
<td>
".$relatienummer."
</td>
</tr>
<tr>
<td>Aanhef</td>
<td>
".$aanhef."
</td>
</tr>
<tr>
<td>Contactpersoon</td>
<td>
".$contactpersoon."
</td>
</tr>
<tr>
<td>mailadres</td>
<td>
".$emailadres."
</td>
</tr>
<td>Jaar</td>
<td>
".$jaar."
</td>
</tr>
</table>";
In the email it shows :
<table border='0' width='40%'>
<tr>
<td>Bedrijfsnaam</td>
<td>
Bob
</td>
</tr>
<tr>
<td>Risicoadres</td>
<td>
Bobstreet 12
</td>
</tr>
<tr>
<td>Adres</td>
<td>
Bobstreet 12
</td>
</tr>
<tr>
<td>Woonplaats</td>
<td>
England
</td>
</tr>
<tr>
<td>Relatienummer</td>
<td>
123456
</td>
</tr>
<tr>
<td>Aanhef</td>
<td>
Dear guy
</td>
</tr>
<tr>
<td>Contactpersoon</td>
<td>
Bob
</td>
</tr>
<tr>
<td>mailadres</td>
<td>
BOB#bobbv.nl
</td>
</tr>
<td>Jaar</td>
<td>
2028
</td>
</tr>
</table>";
My mail() =
mail($email_naar, $email_onderwerp, $email_bericht);
mail($emailadres, $email_onderwerp, $email_bericht);
It shows all the table/tr's/td's etc in the mail that has been send to the email adress any way to solve this problem do i need to use a html tag or something?
if send mail without header information it will take table,tr,td as string
you need to in include
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '. $sendermail . "\r\n";
mail($to, $subject, $message, $headers)
You need to set
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
And then:
mail($email_naar, $email_onderwerp, $email_bericht, $headers);
You need to add headers to your mail() call (fourth parameter)
Specifically for your purpose you need (with relevant charset)
'Content-type: text/html; charset=iso-8859-1';
Please, refer to http://php.net/manual/en/function.mail.php to learn more about sending headers in e-mail. You'll need some of them, like 'Reply-To' and some others
I think mail() function sending mail as a plain text where HTML part will not be rendered.
Here is the sample program to send HTML email. (copy and paste from php.net)
<?php
// multiple recipients
$to = 'aidan#example.com' . ', '; // note the comma
$to .= 'wez#example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
Code source from http://php.net/manual/en/function.mail.php

Copy HTML form in email PHP

I am trying to copy my HTML form in email body. Below is code where the form is already in php file but I want if the user submits html form file then all the form data between that is not hidden is copied (as disabled elements) in the body of the email. Also if there is any file attachment field, it should be attached to the email.
<?php
// multiple recipients
$to = 'demo#localhost.com' . ', '; // note the comma
$to .= 'demo#localhost.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body style="padding:3px; margin:0px;" bgcolor="#FFFFFF">
<table cellpadding="0" cellspacing="0" border="0" width="440">
<tr><td style="height:10px"></td></tr>
<tr>
<td colspan="2" style="text-align:justify; line-height:15px;" class="body">
<form name="frm" method="POST" action="careersuccess.php" enctype="multipart/form-data">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="23%" class="body"> Name</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strname" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Address</td>
<td width="3%" class="body">:</td>
<td width="74%"><textarea cols="16" name="straddress"></textarea></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> City</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strcity" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> State</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strstate" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Contact No</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strno" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Email</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="stremail" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Comments</td>
<td width="3%" class="body">:</td>
<td width="74%"><textarea cols="16" name="strcomments"></textarea></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Resume</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="file" name="strresume"></td>
</tr>
<tr><td style="height:10px"></td></tr>
<tr>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
I'll assume the form is submitted from a website, and that you're not trying to create a submittable form in an email. To copy the data submitted in the form, $_POST[""]; would surely be the best way to obtain the data. Obviously the data wouldn't be manipulatable once the email has arrived in the recipient's inbox but, as I say, I'm assuming you're not trying to create a form which can be submitted from an email.
Your form on the website was fine:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body style="padding:3px; margin:0px;" bgcolor="#FFFFFF">
<table cellpadding="0" cellspacing="0" border="0" width="440">
<tr><td style="height:10px"></td></tr>
<tr>
<td colspan="2" style="text-align:justify; line-height:15px;" class="body">
<form name="frm" method="POST" action="careersuccess.php" enctype="multipart/form-data">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="23%" class="body"> Name</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strname" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Address</td>
<td width="3%" class="body">:</td>
<td width="74%"><textarea cols="16" name="straddress"></textarea></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> City</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strcity" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> State</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strstate" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Contact No</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="strno" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Email</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="stremail" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Comments</td>
<td width="3%" class="body">:</td>
<td width="74%"><textarea cols="16" name="strcomments"></textarea></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Resume</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="file" name="strresume"></td>
</tr>
<tr><td style="height:10px"></td></tr>
<tr>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
</table>
</body>
</html>
Your file careersuccess.php would then need to include something like:
<?php
// multiple recipients
$to = 'demo#localhost.com' . ', '; // note the comma
$to .= 'demo#localhost.com';
// subject
$subject = 'Birthday Reminders for August';
$strName = $_POST["strname"]; //assigns strname from form to PHP variable
$strAddress = $_POST["straddress"];
$strCity = $_POST["strcity"];
$strState = $_POST["strstate"];
$strNumber = $_POST["strnumber"];
$strEmail = $_POST["stremail"];
$strComments = $_POST["strcomments"];
$strResume = $_POST["strresume"];
$lineBreak = "<br />\n\"; //adds carriage return to break up your message
$message = "Name: ".$strName.$lineBreak."Address: ".$strAddress.$lineBreak."City: ".$strCity.$lineBreak."State: ".$strState.$lineBreak...for the rest of your variables;
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
That will result in the submitted values of the form being copied in to the email in the $message variable for the mail() function.

Categories