I use a simple section of php in my header to send the contents of a mysqli query (in this case a combination of three queries - 'ORDER' has the shipping details, 'CUSTOMER' contains the email details of the customer, and 'PRODLIST' has a list of products entered into the shopping cart)
I put together the following script, trying to collect the 'ORDER' details, and add a repeating region to add all the records in the 'PRODLIST' query.
It didn't work, and I was wondering if this is even possible, and if not is there a solution that will allow me to send a simple html email with the full details?
Both queries are working by the way, they are listed on screen in the actual web page, but the mail code is not responding, and causing the page not to load.
$to = 'RECIPIENT REMOVED';
$subject = "order from " . $ORDER->getColumnVal("CUSTOMER_NAME");
$headers = "From: " . $CUSTOMER->getColumnVal("EMAIL") . "\r\n";
$headers .= "Reply-To: ". $CUSTOMER->getColumnVal("EMAIL") . "\r\n";
$headers .= "BCC: info#sigwebdesign.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";$from = "<".$CUSTOMER->getColumnVal("EMAIL").">";
$message = '<html><body>';
$message .= '<p>The following order has been received</p>';
$message .= "Delivery Type: " . $ORDER->getColumnVal("DELIVERY_TYPE") . "<br>";
$message .= "<b>Delivery Date: " . $ORDER->getColumnVal("DELIVERY_DATE") . "<br><br><br></b>";
$message .= "Company: " . $ORDER->getColumnVal("CUSTOMER_NAME") . "<br>";
$message .= "Contact: " . $ORDER->getColumnVal("PLACED_BY") . "<br><br>";
$message .= "Address: " . $ORDER->getColumnVal("DELIVERY_ADDRESS") . "<br>";
$message .= "Address: " . $ORDER->getColumnVal("CITY") . "<br>";
$message .= "Address: " . $ORDER->getColumnVal("STATE") . "<br>";
$message .= "Address: " . $$ORDER->getColumnVal("ZIP") . "<br><br><br>";
while(!$PRODLIST->atEnd()) {
$message .= "ITEM: " . $PRODLIST->getColumnVal("GENUS")." ".$PRODLIST->getColumnVal("VARIETY") . "<br>";
$message .= "QTY: " . $PRODLIST->getColumnVal("QUANTITY") . "<br>";
$PRODLIST->moveNext();
}
$PRODLIST->moveFirst();
$message .= "Total Cost: " . $_SESSION['fullcost'] . "<br><br><br>";
$message .= "This price does not include shipping, and applicable taxes. <br> Your order will be processed, and a final confirmation will be sent to you by email or by phone. <br><br>";
$message .= '</html></body>';
mail($to,$subject,$message,$headers);
So I worked it out. I added an extra "$" in the coding, and it threw a whole big spanner in the works.
so the answer (note to self at least) is check check and triple check the code!
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm not sure why but this has suddenly stopped sending out emails. I have tried to test the email server using mail("email#domain.com","test","test message"); and it sends it fine. I have a feeling something is wrong with my headers?
I have tried to send it with and without attachments but it is not working.
Any help would be greatly appreciated.
Thanks in advance!
<?php
extract($_POST);
$dir = '../uploads/';
$files_temp = scandir($dir, 1);
foreach ($files_temp as $key=>$value) {
if (strpos($value,$file_id) !== false) {
$files[] = $value;
}
}
$message = "";
$message .= "Firm: " . $_POST['firm'] . "\n";
$message .= "Attorney: " . $_POST['attorney'] . "\n";
$message .= "Main Contact: " . $_POST['main_contact'] . "\n";
$message .= "Phone: " . $_POST['phone'] . "\n";
$message .= "Cell: " . $_POST['cell'] . "\n";
$message .= "Fax: " . $_POST['fax'] . "\n";
$message .= "Address: " . $_POST['address'] . "\n";
$message .= "Email: " . $_POST['email'] . "\n";
$message .= "Court County: " . str_replace("_"," ",$_POST['court_county']) . "\n";
$message .= "Court Name: " . $_POST['court_name'] . "\n";
$message .= "Case Type: " . str_replace("_"," ",$_POST['case_type']) . "\n";
$message .= "Appearance Type: " . $_POST['appearance_type'] . "\n";
$message .= "Date: " . $_POST['date'] . "\n";
$message .= "Time: " . $_POST['time'] . "\n";
$message .= "Department: " . $_POST['department'] . "\n";
$message .= "Case Name: " . $_POST['case_name'] . "\n";
$message .= "Case Number: " . $_POST['case_number'] . "\n";
$message .= "Your Client: " . $_POST['your_client'] . "\n";
$message .= "Client Present: " . $client_present_text . "\n";
$message .= "What do you want the attorney to accomplish at this hearing?: " . $_POST['text1'] . "\n";
$message .= "Explain case background: " . $_POST['text2'] . "\n";
$message .= "Signature: " . $_POST['signature'] . "\n";
// email fields: to, from, subject, and so on
$to = "email#domain.com";
$from = "email#domain.com";
$subject ="Appearance form";
$headers = "From: $from";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
// preparing attachments
for($x=0;$x<count($files);$x++){
$file = fopen($dir.$files[$x],"rb");
$data = fread($file,filesize($dir.$files[$x]));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
}
// send
$ok = #mail($to, $subject, $message, $headers);
Looks like my code wasn't the problem. It was an issue with mailing it from info#mydomain.com. Changed $from variable to a gmail email address and it started sending emails again.
I want to customize an php email with some html but I'm struggling with that...
After submit my form i receive the email but happen this
I was following this tutorial
I put the code i used.
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Alright, lets send the email already!
if ( empty( $errorString ) ) {
$mailbody .= '<html><body>';
$mailbody .= '<img src="//http://xxxx/xxxxx/wp-content/uploads/2015/06/email.jpg" alt="Website Change Request" />';
$mailbody .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$mailbody .= __('Nome:', 'ci_theme' ) . ' ' . $clientname . "\n";
$mailbody .= __('Email:', 'ci_theme' ) . ' ' . $email . "\n";
$mailbody .= __('Chegada:', 'ci_theme' ) . ' ' . $arrive . "\n";
$mailbody .= __('Saída:', 'ci_theme' ) . ' ' . $depart . "\n";
$mailbody .= __('Adultos:', 'ci_theme' ) . ' ' . $guests . "\n";
$mailbody .= __('Crianças:', 'ci_theme' ) . ' ' . $children . "\n";
$mailbody .= __('Quarto:', 'ci_theme' ) . ' ' . $room->post_title . "\n";
$mailbody .= __('Mensagem:', 'ci_theme' ) . ' ' . $message . "\n";
$mailbody .= __('Hora do Check-in (hh:mm):', 'ci_theme' ) . ' ' . $timeguest . "\n";
$mailbody .= __('Contacto:', 'ci_theme' ) . ' ' . $contactguest . "\n";
$mailbody .= __('Autorização:', 'ci_theme' ) . ' ' . $autorizo . "\n";
$mailbody .= __('Cama Extra:', 'ci_theme' ) . ' ' . $camaextra . "\n";
$mailbody .= "</table>";
$mailbody .= "</body></html>";
mail($to, $mailbody, $headers);
// If you want to receive the email using the address of the sender, comment the next $emailSent = ... line
// and uncomment the one after it.
// Keep in mind the following comment from the wp_mail() function source:
/* If we don't have an email from the input headers default to wordpress#$sitename
* Some hosts will block outgoing mail from this address if it doesn't exist but
* there's no easy alternative. Defaulting to admin_email might appear to be another
* option but some hosts may refuse to relay mail from an unknown domain. See
* http://trac.wordpress.org/ticket/5007.
*/
//$emailSent = wp_mail(ci_setting('booking_form_email'), get_option('blogname').' - '. __('Booking form', 'ci_theme'), $mailbody);
$emailSent = wp_mail(ci_setting('booking_form_email'), get_option('blogname').' - '. __('Formulário de Reserva','theme-text-domain', 'ci_theme'), $mailbody, 'From: "'.$clientname.'" <'.$email.'>');
$emailSent2 = wp_mail( $email, __('Booking Inquiry','theme-text-domain', 'ci_theme'), __('Thank you so much for your interest in Hotel Aveiro Center! We will get back to you within 24 hours to answer your request.','theme-text-domain','ci_theme'),'From: Hotel Aveiro Center <xxxx#xxxx>');
}
Here is a simple example I have done .
//build email to be sent
$to = $email;
$subject = $site_url;
$subject .= ": Activate Your Account";
$message = "
<html>
<head>
<title>Account Activation</title>
</head>
<body>
<h3>Account Activation</h3>
<p>Dear ".$user.", thank you for registering at ".$site_url.".</p>
<p>Please click on the link below to activate your account:</p>
<a href='".$site_url."/confirm_user_reg.php?activation_key=".$activation_key."'>http://www.".$site_url."</a>.
<p>If the above link does not work, copy and paste the below URL to your browser's address bar:</p>
<p><i>http://www.".$site_url."/confirm_user_reg.php?activation_key=".$activation_key."</i></p><br/>
<p>If you did not initiate this request, simply disregard this email, and we're sorry for bothering you.</p>
<br/><br/>
<p>Sincerely,</p>
<p>The ".$site_url." Team.</p>
</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";
This question already has an answer here:
HTML in php mail function
(1 answer)
Closed 8 years ago.
I have read a couple of posts on here about this already, so I know that I need to use the file_get_contents function to do this, but I have a bit more advanced need. I need to be able to call in data submitted by a user as well as call in the needed HTML to make the email look nicer. Here is some of my code:
First off, know the structure I have, inside index.php is my html form, and action="complete.php".
At the top of complete.php, I have this:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$evaluator_email = $_POST["evaluator_email"];
$teacher_email = $_POST["teacher_email"];
$evaluator = $_POST["evaluator"];
$teacher = $_POST["teacher"];
$date = $_POST["date"];
$teacher_body = "Hello " . $teacher . ", recently, " . $evaluator . " created a teacher evaluation for your session on " . $date . ". ";
$evaluator_body = "Hello " . $evaluator . ", your evaluation of " . $teacher . " was successfully sent to " . $teacher_email . ". ";
mail($teacher_email , "Evaluation" , $teacher_body , "From: $evaluator");
mail($evaluator_email , "Evaluation" , $evaluator_body , "From: Teacher Evaluation Tool");
}
?>
Which all works fine, but now I want to be able to include HTML. How can I make $teacher_body and $evaluator_body equal a file that contains the HTML that I write, and still have access to the PHP variables such as $teacher, $evaluator, $date, etc?
Example send an HTML email:
<?php
$to = "somebody#example.com, somebodyelse#example.com";
$subject = "HTML email";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <webmaster#example.com>' . "\r\n";
$headers .= 'Cc: myboss#example.com' . "\r\n";
mail($to,$subject,$message,$headers);
?>
I usually use placeholders in situations like this. For example in the HTML file I'll put things like "TEACHER" and "EVALUATOR" etc. Then my PHP can be something along the lines of:
$html = file_get_contents("myFileWithPlaceholders.htm");
$html = str_replace ( "TEACHER", $teacher, $html );
$html = str_replace ( "EVALUATOR", $evaluator, $html );
Just make sure your placeholders are very unique and you should be fine.
It is highly recommended to use PHPMailer.
https://phpbestpractices.org/#email
From this best practices website:
"PHP provides a mail() function that looks enticingly simple and easy. Unfortunately, like a lot of things in PHP, its simplicity is deceptive and using it at face value can lead to serious security problems.
Email is a set of protocols with an even more tortured history than PHP. Suffice it to say that there are so many gotchas in sending email that just being in the same room as PHP's mail() function should give you the shivers.
PHPMailer is a popular and well-aged open-source library that provides an easy interface for sending mail securely. It takes care of the gotchas for you so you can concentrate on more important things."
The library can be found here:
https://github.com/PHPMailer/PHPMailer
Easy to use and works great for sending HTML and text-based emails!
This is same as sending text in email. Just add the extra tags with a dot(.) operator.
For example:
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['req-name']) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['req-email']) . "</td></tr>";
$message .= "<tr><td><strong>Type of Change:</strong> </td><td>" . strip_tags($_POST['typeOfChange']) . "</td></tr>";
$message .= "<tr><td><strong>Urgency:</strong> </td><td>" . strip_tags($_POST['urgency']) . "</td></tr>";
$message .= "<tr><td><strong>URL To Change (main):</strong> </td><td>" . $_POST['URL-main'] . "</td></tr>";
$addURLS = $_POST['addURLS'];
if (($addURLS) != '') {
$message .= "<tr><td><strong>URL To Change (additional):</strong> </td><td>" .strip_tags($addURLS) . "</td></tr>";
}
$curText = htmlentities($_POST['curText']);
if (($curText) != '') {
$message .= "<tr><td><strong>CURRENT Content:</strong> </td><td>" . $curText . "</td></tr>";
}
$message .= "<tr><td><strong>NEW Content:</strong> </td><td>" .htmlentities($_POST['newText']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
// Always set headers
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <webmaster#example.com>' . "\r\n";
$headers .= 'Cc: myboss#example.com' . "\r\n";
now send the email with:
mail($to, $subject, $message, $headers);
I have a rather large form that when filled out and submitted, I want the data to be formed into a CSV file and emailed to a specific email address.
Does anyone know if it is all at all possible to add a file upload function to the bottom of this form?
This is for a client and have just encountered limitations in my knowledge of PHP.
This is the code I am using:
<?php
if(isset($_POST['formSubmit'])) {
$email=$_REQUEST['email'];
$firstName=$_REQUEST['firstName'];
$lastName=$_REQUEST['lastName'];
$to = "***#***.co.uk";
$subject = "New application submission";
$message = "".
"Email: $email" . "\n" .
"First Name: $firstName" . "\n" .
"Last Name: $lastName";
//The Attachment
$varTitle = $_POST['formTitle'];
$varForname = $_POST['formForname'];
$varMiddlename = $_POST['formMiddlename'];
$varSurname = $_POST['formSurname'];
$varKnownas = $_POST['formKnownas'];
$varAdressline1 = $_POST['formAdressline1'];
$varAdressline2 = $_POST['formAdressline2'];
$varAdressline3 = $_POST['formAdressline3'];
$varAdressline4 = $_POST['formAdressline4'];
$varAdressline5 = $_POST['formAdressline5'];
$varPostcode = $_POST['formPostcode'];
$varTelephone = $_POST['formTelephone'];
$varMobile = $_POST['formMobile'];
$varEmail = $_POST['formEmail'];
$varApproval = $_POST['formApproval'];
$varothersurname = $_POST['formothersurname'];
$varsex = $_POST['formsex'];
$varninumber = $_POST['formninumber'];
$varjobtitle = $_POST['formjobtitle'];
$vardates = $_POST['formdates'];
$varresponsibilities = $_POST['formresponsibilities'];
$varjobtitle2 = $_POST['formjobtitle2'];
$vardates2 = $_POST['formdates2'];
$varresponsibilities2 = $_POST['formresponsibilities2'];
$varjobtitle3 = $_POST['formjobtitle3'];
$vardates3 = $_POST['formdates3'];
$varresponsibilities3 = $_POST['formresponsibilities3'];
$varwebsite = $_POST['formwebsite'];
$vartshirt = $_POST['formtshirt'];
$vardietary = $_POST['formdietary'];
$varpc = $_POST['formpc'];
$varmac = $_POST['formmac'];
$varlaptop = $_POST['formlaptop'];
$vardongle = $_POST['formdongle'];
$varediting = $_POST['formediting'];
$varsocial = $_POST['formsocial'];
$varphotography = $_POST['formphotography'];
$varfilming = $_POST['formfilming'];
$vartraining = $_POST['formtraining'];
$varexhibition = $_POST['formexhibition'];
$varspecial = $_POST['formspecial'];
$varhobbies = $_POST['formhobbies'];
$varphotography = $_POST['formphotography'];
$varfilming = $_POST['formfilming'];
$vartraining = $_POST['formtraining'];
$varexcel = $_POST['formexcel'];
$varbigpicture = $_POST['formbigpicture'];
$varcriminal = $_POST['formcriminal'];
$attachments[] = Array(
'data' => $data,
'name' => 'application.csv',
'type' => 'application/vnd.ms-excel' );
//Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
//Add the headers for a file attachment
$headers = "MIME-Version: 1.0\n" .
"From: {$from}\n" .
"Cc: davidkirrage#gmail.com\n".
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
//Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$text . "\n\n";
//Add sttachments
foreach($attachments as $attachment){
$data = chunk_split(base64_encode($attachment['data']));
$name = $attachment['name'];
$type = $attachment['type'];
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" ;
$message = "--{$mime_boundary}--\n";
mail($to, $subject, $message, $headers);
header('Location: http://bigpictest.co.uk/thanks.php');
exit();
}
}
?>
There is no need to go to so much trouble.
The following will probably help:
$filename="directory/csvfile.csv"; //specify filename and path
$keys=array_keys($_POST); //get list of post keys
$file=fopen($filename,"w"); //open a csv file to write to;
fputcsv($file,$keys); //write post keys as first line of CSV file.
fputcsv($file,$_POST); //write post data as second line of csv file.
fclose($file); //close the file.
The csv file you need to attach is created thus. No need for all those variables.
I haven't checked your mail code. If you are having problems with attaching the file, please ask a different question about that (though there are doubtless answers here already)
Good luck!
I've done this in asp and asp.net but never had to do it with php (that is sending mail with attachments from the server).
The thing to understand is that when you submit the form, the data is being sent to be processed somewhere, lets say: FormProcessor which may be in a separate file or in the php page itself.
So when the FormProcessor receives the data, you can combine it or format it in anyway you like.
You would need access to the filesystem to create the file on the server.
Let's say that the function for sending email is in the FormProcessor scope.
You can use email headers to add the attachment when you define the email object.
This is one of my send email funcitons in php which I've modified to use as a sample here:
function FormProcessor_SendEmail($v){ // $v is an array containing the data to use for sending the email
// parameters = $v[0] = user email, $v[1] = business name,
// $v[2] = address, $v[3] = city, $v[4] = state, $v[5] = zip code,
// $v[6] = phone, $v[7] = message, $v[8] = service area
$eol = "\r\n";
$tb = "\t";
$stb = "\t\t";
// notify new registrant
$to = $v[0];
$subject = "This is the subject text";
$message = "Date : " . $this->prepare_new_timestamp() . ".<br /><br />" . $eol;
$message .= "Thank you for requesting more information about " . $this->get_sitename() . "<br /><br />" . $eol;
$message .= "We will be contacting you as soon as possible<br />" . $eol;
$message .= "with information that is tailored to your needs and interests.<br /><br />" . $eol;
$message .= "We have received the following information from you:<br /><br />" . $eol;
$message .= "Your Business Name: " . $v[1] . "<br />" . $eol;
$message .= "Business Address: " . $v[2] . "<br />" . $eol;
$message .= "City: " . $v[3] . "<br />" . $eol;
$message .= "State: " . $v[4] . "<br />" . $eol;
$message .= "Zip Code: " . $v[5] . "<br />" . $eol;
$message .= "Phone: " . $v[6] . "<br />" . $eol;
$message .= "Service Area: " . $v[8] . "<br />" . $eol;
$message .= "Message: <br />" . $v[7] . "<br /><br />" . $eol;
$message .= "If you have additional questions, please address them to: " . $this->get_support_email() . "<br />" . $eol;
$message .= "or by phone at: " . $this->get_support_phone() . "<br /><br />" . $eol;
$message .= "If you did not submit this request, please contact us and let us know<br />" . $eol;
$message .= "so that we may take the proper actions necessary.<br /><br />" . $eol;
$message .= "Sincerely,<br />" . $eol;
$message .= "The Team at " . $this->get_sitename() . "<br />" . $eol;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: sitename <' . $this->get_webmaster_email() . '>' . "\r\n";
$headers .= 'Cc: webmaster <' . $this->get_webmaster_email() . '>' . "\r\n";
mail($to,$subject,$message,$headers);
return 1;
}
It doesn't send an attachment, but I'm sure someone else on this site can help you find a better way.
Hope it helps.
I'm creating a user require form in my site. For this I put some validation on compulsory fields, and when a user fills in the form and presses submit and validation is correct then I receive a email on my email address.
But now I would like all user information in the email, like name, city, budget etc... so what changes do I need to make in my email.php script?
If some fields are not compulsory and the user doesn't fill them in, can they affect my script?
My script is:
<?php
$to = "test#networkers.in";
$subject = "a new requiremnet come!";
$message = "Hi,\n\nyou get a new require";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "Sender-IP: " . $_SERVER["SERVER_ADDR"] . "\r\n";
$headers .= "From: " . stripslashes($name) . " <" . $email . ">" . "\r\n";
$headers .= "Priority: normal" . "\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
$sent = mail($to, $subject, $message, $headers) ;
if ($sent) {
echo "Your mail was sent successfully";
} else {
echo "We encountered an error sending your mail";
}
?>
and the data I recieve is:
$name = $_POST['fname'].' '.$_POST['lname'];
$email = $_POST['mail'];
$phone = $_POST['ph'];
$country = $_POST['country'];
$pt = $_POST['pt'];
$cwl = $_POST['cwl'];
$dyhyows = $_POST['dyhyows'];
$pb = $_POST['pb'];
$bpd = $_POST['bpd'];
$hdyhau = $_POST['hdyhau'];
You can add fields to the message body by concatenating them like so:
$message = "Hi,\n\nyou get a new require";
$message .= "\n Name: " . $name;
$message .= "\n Email: " . $email;
$message .= "\n Phone: " . $phone;
$message .= "\n Country: " . $country;
$message .= "\n pt: " . $pt;
$message .= "\n cwl: " . $cwl;
$message .= "\n dyhyows: " . $dyhyows;
$message .= "\n pb: " . $pb;
$message .= "\n bpd: " . $bpd;
$message .= "\n hdyhau: " . $hdyhau
Any fields that weren’t filled in by the user will simply be blank.