Contact Form Sending 3 Copies to Recipient - php

I have a contact form on my website which calls a .php mail handler to send off the inquiries. Each time an inquiry is sent off I receive 3 copies of the email.
Any ideas what could be causing this?
The following script is in the header:
<script type="text/javascript">
$(window).load(function(){
$('#form').TMForm({
ownerEmail:'admin#endlessflooring.co.nz'
})
})
</script>
The contact form is as follows:
<form id="form">
<div class="success_wrapper">
<div class="success-message">Contact form submitted</div>
</div>
<label class="name">
<input type="text" placeholder="Name" data-constraints="#Required
#JustLetters" />
<span class="empty-message">*This field is required.</span>
<span class="error-message">*This is not a valid name.</span>
</label>
<label class="email">
<input type="text" placeholder="E-mail" data-constraints="#Required #Email" />
<span class="empty-message">*This field is required.</span>
<span class="error-message">*This is not a valid email.</span>
</label>
<label class="phone">
<input type="text" placeholder="Phone" data-constraints="#Required #JustNumbers"/>
<span class="empty-message">*This field is required.</span>
<span class="error-message">*This is not a valid phone.</span>
</label>
<label class="state">
<input type="text" placeholder="City" data-constraints="#Required #JustLetters"/>
<span class="empty-message">*This field is required.</span>
<span class="error-message">*This is not a valid city.</span>
</label>
<label class="message">
<textarea placeholder="Message" data-constraints='#Required #Length(min=2,max=999999)'></textarea>
<span class="empty-message">*This field is required.</span>
<span class="error-message">*The message is too short.</span>
</label>
<div>
<div class="clear"></div>
<div class="btns">
send message</div>
</div>
</form>
And the mail handler is as follows:
<?php
//SMTP server settings
$host = "smtp.host.com";
$port = "587";
$username = "";
$password = "";
$messageBody = "";
if($_POST['name']!='false'){
$messageBody .= '<p>Name: ' . $_POST["name"] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['email']!='false'){
$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}else{
$headers = '';
}
if($_POST['phone']!='false'){
$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['state']!='false'){
$messageBody .= '<p>Suburb: ' . $_POST['state'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['message']!='false'){
$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
}
if($_POST["stripHTML"] == 'true'){
$messageBody = strip_tags($messageBody);
}
if($host=="" or $username=="" or $password==""){
$owner_email = $_POST["owner_email"];
$headers = 'From:' . $_POST["email"] . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n";
$subject = 'Endless Flooring Quote Request';
try{
if(!mail($owner_email, $subject, $messageBody, $headers)){
throw new Exception('mail failed');
}else{
echo 'mail sent';
}
}catch(Exception $e){
echo $e->getMessage() ."\n";
}
}else{
require_once 'Mail.php';
$to = $_POST["owner_email"];
$subject = 'Endless Flooring Quote Request' . $_POST["name"];
$headers = array (
'From' => 'From:' . $_POST["email"] . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n",
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory(
'smtp',
array (
'host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $messageBody);
try{
if(PEAR::isError($mail)){
echo $mail->getMessage();
}else{
echo 'mail sent';
}
}catch(Exception $mail){
echo $mail->getMessage() ."\n";
}
}
?>

Related

PHP - Email form is sending over 50 mails after form submit

I have a problem that after I fill out the contact form on my HTML website I receive over 50 same E-mails. Its a HTML form connected to contact.php file which code is shown bellow. I have set everything but maybe there is a problem in my code or somewhere else.
My code is over here
<?php
if(!$_POST) exit;
// Email address verification, do not edit.
function isEmail($email) {
return(preg_match("/^[-_.[:alnum:]]+#((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+ (ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email));
}
if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$comments = $_POST['comments'];
$verify = $_POST['verify'];
if(trim($name) == '') {
echo '<div class="error_message">Vyplnte meno.</div>';
exit();
} else if(trim($email) == '') {
echo '<div class="error_message">Vyplnte email.</div>';
exit();
} else if(!isEmail($email)) {
echo '<div class="error_message">Zadali ste nesprávny e-mail, skúste to znovu.</div>';
exit();
}
if(trim($comments) == '') {
echo '<div class="error_message">Vyplnte text správy.</div>';
exit();
}
if(get_magic_quotes_gpc()) {
$comments = stripslashes($comments);
}
// Configuration option.
// Enter the email address that you want to emails to be sent to.
// Example $address = "joe.doe#yourdomain.com";
$address = "noreply#marcelaskolenia.sk";
$address = "lubosmasura#gmail.com";
$toCustomer = $email;
// Configuration option.
// i.e. The standard subject will appear as, "You've been contacted by John Doe."
// Example, $e_subject = '$name . ' has contacted you via Your Website.';
$e_subject = 'Mate novu spravu od ' . $name . '.';
// Configuration option.
// You can change this if you feel that you need to.
// Developers, you may wish to add more fields to the form, in which case you must be sure to add them here.
$e_body = "Mate novu spravu od $name." . PHP_EOL . PHP_EOL;
$e_content = "\"$subject\"" . "\"$comments\"" . PHP_EOL . PHP_EOL;
$e_reply = "Kontaktujte $name cez email, $email alebo cez mobil $phone";
$msg = wordwrap( $e_body . $e_content . $e_reply, 70 );
$headers .= 'To: Test <noreply#marcelaskolenia.sk>' . "\r\n";
$headers .= 'From: Testk <noreply#marcelaskolenia.sk>' . "\r\n";
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;
if(mail($address, $e_subject, $msg, $headers)) {
// Email has sent successfully, echo a success page.
echo "<fieldset>";
echo "<div id='success_page'>";
echo "<h3 class'mark'>Sprava bola odoslana.</h3>";
echo "<p>Dakujeme <strong>$name</strong>, Vasa sprava nam bude dorucena.</p>";
echo "</div>";
echo "</fieldset>";
} else {
echo 'ERROR!';
}
HTML code
<div class="contact_form">
<div id="message"></div>
<form id="contactform" class="row" action="contact.php" name="contactform" method="post">
<div class="col-md-12">
<input type="text" name="name" id="name" class="form-control" placeholder="Meno">
<input type="text" name="email" id="email" class="form-control" placeholder="Email">
<input type="text" name="phone" id="phone" class="form-control" placeholder="Telefónne číslo">
<input type="text" name="subject" id="subject" class="form-control" placeholder="Predmet">
<textarea class="form-control" name="comments" id="comments" rows="6" placeholder="Text správy"></textarea>
<button type="submit" value="SEND" id="submit" class="btn btn-primary"> ODOSLAŤ</button>
</div>
</form>
</div>
</div><!-- end col -->
Any Ideas why is this happening?
Thank you.

How to replay to sender email from PHP instead of CGI-Mailer

I have tried too many different ways to get reply-to from the $_request[email] but it keeps sending the mails with the $from CGI- mailer, although all the body on my mail work´s fine..
I have tried too many ways but i can't find where is my problem.. i have looked at several answers to this question here but not any one fixes my problem.. this is my code.
<?php
$subject = 'Contacact from website';
$to = 'contact#myhosting.com';
$emailTo = $_REQUEST['email'];
// an email address that will be in the From field of the email.
$name = $_REQUEST['name'];
$email = $_REQUEST['email']; // i can't get this going to the reply-to section on the mail
$phone = $_REQUEST['phone'];
$msg = $_REQUEST['message'];
$email_from = $name.'<'.$email.'>';
$headers = "MIME-Version: 1.1";
$headers .= "Content-type: text/html; charset=utf-8";
$headers .= 'From: ' . $fromName . ' <' . $fromEmail .'>' . " \r\n" .
'Reply-To: '. $fromEmail . "\r\n" .
'X-Mailer: PHP/' . phpversion();
// Send email
mail($sendTo, $subject, $emailText, implode("\n", $headers));
$message .= 'Name : ' . $name . "\n";
$message .= 'Email : ' . $email . "\n";
$message .= 'phone : ' . $phone . "\n";
$message .= 'Message : ' . $msg;
if (#mail($to, $subject, $message, $email_from)) {
// Transfer the value 'sent' to ajax function for showing success message.
echo 'sent';
} else {
// Transfer the value 'failed' to ajax function for showing error message.
echo 'failed';
}
?>
and this is my form:
<form name="contactForm" id='contact_form' method="post" action='email.php'>
<div class="row">
<div class="col-md-4">
<div id='name_error' class='error'>write your name</div>
<div>
<input type='text' name='name' id='name' class="form-control" placeholder="Name">
</div>
<div id='email_error' class='error'>Write a valid email</div>
<div>
<input type='email' name='email' id='email' class="form-control" placeholder="
email">
</div>
<div id='phone_error' class='error'>Write a phone number.</div>
<div>
<input type='tel' name='phone' id='phone' class="form-control" placeholder="Your name">
</div>
</div>
<div class="col-md-8">
<div id='message_error' class='error'>Please write your message here</div>
<div>
<textarea name='message' id='message' class="form-control"
placeholder="Message or quotation"></textarea>
</div>
</div>
<div class="col-md-12">
<p id='submit'>
<input type='submit' id='send_message' value='Enviar' class="btn btn-line">
</p>
<div id='mail_success' class='success'>We received your message :)</div>
<div id='mail_fail' class='error'>Please try again :/</div>
</div>
</div>
</form>
There are a few things wrong with what you posted.
Firstly, the first line for this block of code:
$message .= 'Name : ' . $name . "\n";
$message .= 'Email : ' . $email . "\n";
$message .= 'phone : ' . $phone . "\n";
$message .= 'Message : ' . $msg;
should not have a leading dot for $message .=, it should read as:
$message = 'Name : ' . $name . "\n";
Then this line:
if (#mail($to, $subject, $message, $email_from))
Since you're using $email_from as the last argument, mail() as you did for the other instance where you are sending mail, is using a valid From: with an E-mail address as it's coming "from", when the 2nd one does not contain that, you only declared it as $email_from = $name.'<'.$email.'>';.
What you will need to do is add the From: as you did for the first mailing instance.
Side note: The # symbol is an error suppressor. You might want to remove that during testing/development.
Consult the manual on the mail() function for more detail:
https://www.php.net/manual/en/function.mail.php

How to setup a contact form from a templatemonster template I purchased?

I purchased a template from Template Monster and I can't figure out how to make the form work.
Here's the form code:
<form id="form">
<div class="success_wrapper">
<div class="success-message">Το μήνυμά σας εστάλη.</div>
</div>
<label class="name">
<input type="text" placeholder="Όνομα*:" data-constraints="#Required #JustLetters" />
<span class="empty-message">*Το πεδίο είναι υποχρεωτικό.</span>
<span class="error-message">*Το όνομα δεν είναι έγκυρο.</span>
</label>
<label class="email">
<input type="text" placeholder="Email*:" data-constraints="#Required #Email" />
<span class="empty-message">*Το πεδίο είναι υποχρεωτικό.</span>
<span class="error-message">*Το email δεν είναι έγκυρο.</span>
</label>
<label class="phone">
<input type="text" placeholder="Τηλέφωνο:" data-constraints=" #JustNumbers"/>
<span class="empty-message">*Το πεδίο είναι υποχρεωτικό.</span>
<span class="error-message">*Το τηλέφωνο δεν είναι έγκυρο.</span>
</label>
<label class="message">
<textarea placeholder="Μήνυμα:" data-constraints=' #Length(min=20,max=999999)'></textarea>
<span class="empty-message">*Το πεδίο είναι υποχρεωτικό.</span>
<span class="error-message">*Το μήνυμα είναι πολύ μικρό.</span>
</label>
<div>
<div class="clear"></div>
<div class="btns">
Καθαρισμος
Αποστολη</div>
</div>
</form>
There is also a MailHandler.php in a folder named "bat" with the following code:
<?php
//SMTP server settings
$host = "smtp.host.com";
$port = "587";
$username = "";
$password = "";
$messageBody = "";
if($_POST['name']!='false'){
$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['email']!='false'){
$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}else{
$headers = '';
}
if($_POST['state']!='false'){
$messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['phone']!='false'){
$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['fax']!='false'){
$messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['message']!='false'){
$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
}
if($_POST["stripHTML"] == 'true'){
$messageBody = strip_tags($messageBody);
}
if($host=="" or $username=="" or $password==""){
$owner_email = $_POST["owner_email"];
$headers = 'From:' . $_POST["email"] . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n";
$subject = 'A message from your site visitor ' . $_POST["name"];
try{
if(!mail($owner_email, $subject, $messageBody, $headers)){
throw new Exception('mail failed');
}else{
echo 'mail sent';
}
}catch(Exception $e){
echo $e->getMessage() ."\n";
}
}else{
require_once 'Mail.php';
$to = $_POST["owner_email"];
$subject = 'A message from your site visitor ' . $_POST["name"];
$headers = array (
'From' => 'From:' . $_POST["email"] . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n",
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory(
'smtp',
array (
'host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $messageBody);
try{
if(PEAR::isError($mail)){
echo $mail->getMessage();
}else{
echo 'mail sent';
}
}catch(Exception $mail){
echo $mail->getMessage() ."\n";
}
}
?>
Any help will be truly appreciated!
Ok I figured this one out... You have to get into the forms javascript file it will look like TMForms.js or something like that in the file named JS, under the very top portion of the code that looks like this
okClass:'ok'
,emptyClass:'empty'
,invalidClass:'invalid'
,successClass:'success'
,onceVerifiedClass:'once-verified'
,mailHandlerURL:'http://www.yourwebsitename.com/bat/MailHandler.php
,successShowDelay:'4000'
,stripHTML:true
MAKE SURE TO PUT THE FULL URL PATH TO THE BAT FOLDER LIKE I HAVE in bold, this will fix your issue.
Replace yourwebsite name with your actual URL and you are good to go...
You must contact the support from where your purchased the template, they can help you

How to send contact form using php

Once I submit the form it will aks me this "We weren't able to send your message. Please contact site#sitenamexample.com It will not send to my WebMail. I can't figureout the problem. I really need your help guys.
$domain = "http://sitenamexample.com" . $_SERVER["HTTP_HOST"];
$siteName ="My Website name";
$siteEmail = "site#sitenamexample.com";
$er = "";
if(isset($_POST["contactEmail"])){
global $subject, $message;
$contactName = htmlentities(substr($_POST["contactName"], 0, 100), ENT_QUOTES);
$contactEmail = htmlentities(substr($_POST["contactEmail"], 0, 100), ENT_QUOTES);
$messageSubject = htmlentities(substr($_POST["messageSubject"], 0, 100), ENT_QUOTES);
$messageContent = htmlentities(substr($_POST["messageContent"], 0, 100), ENT_QUOTES);
if (!preg_match('/' . '^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]{2,})+$' . '/'
, $contactEmail))
{
$er .= 'Please enter a valid e-mail address.<br>';
}
if ($contactName == "" || $contactEmail == "" || $messageSubject == "" ||
$messageContent == ""){
$er .= 'Your Name, E-mail, Message Subject, and Message Content cannot be left
blank.<br />';
}
if($er == ''){
$subject = $messageSubject;
$message =
'<html>
<head>
<title>' . $siteName . ': A Contact Message </title>
.<body>
' . wordwrap($messageContent, 100) . '
</body>
</html>';
}
$to = $siteName . ' Contact Form <' . $siteEmail . '>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=is0-8859-1' . "\r\n";
$headers .= 'From: ' . $contactName . ' <' . $contactEmail . '>' ."\r\n";
$headers .= 'Reply-To: ' . $contactName . ' <' . $contactEmail . '>' . "\r\n";
$headers .= 'Return-Path: ' . $contactName . ' <' . $contactEmail . '>' . "\r\n";
$headers .= 'X-Mailer: ' . $siteName . "\r\n";
if (mail($to, $subject, $message, $headers)){
echo '<div>Thank you for contacting ' . $siteName . '. We will read your message and
contact you if necessary.</div>';
}
else {
$er .= 'We weren\'t able to send your message. Please contact ' . $siteEmail .
'.<br />';
}
}
else {
showContactForm();
}
if ($er != '' && isset($_POST["contactEmail"])){
showContactForm($contactName, $contactEmail, $messageSubject, $messageContent, $er);
}
else if($er != '' && !isset($_POST["contactEmail"])){
showContactForm('', '', '', $er);
}
function showContactForm($contactName = "", $contactEmail = "", $messageSubject = "",
$messageContent = "", $er = ''){
echo '<div style="font-weight:bold; margin: 5px 0; "> ' . $er . '</div>
<div id="email_form">
<h1> Contact Form</h1>
<form method="post" name="contact" action="#contactus">
<label for="name">Name:</label>
<input type="text" id="author" name="contactName" class="input_field" />
<div class="cleaner h10"></div>
<label for="email" class="adjust">Email:</label>
<input type="text" id="email" name="contactEmail" class="input_field" />
<div class="cleaner h10"></div>
<label for="messageSubject" class="adjust">Subject:</label>
<input type="text" id="messageSubject" name="messageSubject" class="input_field" />
<div class="cleaner h10"></div>
<label for="text" class="adjust">Comments:</label>
<textarea id="text" name="messageContent" rows="0" cols="0"></textarea>
<div class="cleaner h10"></div>
<input type="submit" class="submit_btn float_l" name="submitButton" id="submit"
value="Send Message" />
<input type="reset" class="submit_btn float_r" name="reset" id="reset" value="Reset" />
</form>
<div class="clearfix"></div>
</div>';
}
?>
<div class="clearfix"></div>
<?php include ("includes/footer.php"); ?>
You're code is generally correct (but remember - $to should only be the email address without any < or >). I think the reason of your problem is disabled Sendmail PHP Library - you can enable it in server settings or if you have not access to it - read about phpmailer.

Wordpress Contact Form Subject Woes

One of the problems I was experiencing with my last site was the Contact Form - it uses a static subject approach.. which is fine - but the problem is if you use Gmail, then it will group emails of the same subject which isn't ideal, especially if you expect a lot of traffic that way.
On the theme I'm using there's a Subject field, but it doesn't seem to be utilized at all. When I sent my test message, I received:
EMAIL SUBJECT: .am - message from contact form
Site: .am
Name: Alex
Email: test#test.tld
Subject: .am - message from contact form
Message: Test body.
So whatever text I entered into the subject field was completely ignored, and then static text was pulled from the e-mail subject and repeated, again, in the body.
I've located the code in the respective page (I think?).
APOLLO13.PHP
if (empty($name))
$name_error = true;
if (empty($email) || !is_email($email))
$email_error = true;
if (empty($subject))
$subject_error = true;
if (empty($content))
$content_error = true;
if ($name_error == false && $email_error == false && $content_error == false && $subject_error == false) {
$subject = $site . __(' - message from contact form', TPL_SLUG);
$body = __('Site: ', TPL_SLUG) . $site . "\n\n"
. __('Name: ', TPL_SLUG) . $name . "\n\n"
. __('Email: ', TPL_SLUG) . $email . "\n\n"
. __('Subject: ', TPL_SLUG) . $subject . "\n\n"
. __('Message: ', TPL_SLUG) . $content;
$headers = "From: $name <$email>\r\n";
$headers .= "Reply-To: $email\r\n";
if (wp_mail($email_to, $subject, $body, $headers)) {
$title_msg = __('Success sending form', TPL_SLUG);
} else
$title_msg = __('Something wrong. Try again!', TPL_SLUG);
} else {
$title_msg = __('Error in form', TPL_SLUG);
if (!empty($name))
$name_tag = 'value="' . $name . '"';
if (!empty($email))
$email_tag = 'value="' . $email . '"';
if (!empty($subject))
$phone_tag = 'value="' . $subject . '" title="' . __('General question ...', TPL_SLUG) . '"';
if (!empty($content))
$content_tag = $content;
}
And what I want is, essentially
EMAIL SUBJECT: $site | $subject-user-entered
Name:
Email:
Message:
How would I go about amending the code to do that? Because this:
$subject = $site . __(' - message from contact form', TPL_SLUG);
. __('Subject: ', TPL_SLUG) . $subject . "\n\n"
Seems a little pointless.
EDIT
I've found the code for the form itself if that's of any help:
<form action="http<?php echo $ssss ?>://<?php echo $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"] ?>"
method="post" id="contact-form-<?php echo $form_iter ?>" class="contact-form styled-form">
<div class="submit_inputs">
<div<?php echo ($name_error ? ' class="error"' : '') ?>>
<input id="apollo13-contact-name" name="apollo13-contact-name" type="text" value=""/>
<label for="apollo13-contact-name">
<?php echo __('Name', TPL_SLUG) ?>
<span> (<?php echo __('required', TPL_SLUG) ?>)</span>
</label>
</div>
<div style="clear: both;"></div>
<div<?php echo ($name_error ? ' class="error"' : '') ?>>
<input id="apollo13-contact-email" name="apollo13-contact-email" type="text" value="" class="email"/>
<label for="apollo13-contact-email">
<?php echo __('Email', TPL_SLUG) ?>
<span> (<?php echo __('required', TPL_SLUG) ?>)</span>
</label>
</div>
<div style="clear: both;"></div>
<div<?php echo ($name_error ? ' class="error"' : '') ?>>
<input class="placeholder" id="apollo13-contact-subject" name="apollo13-contact-subject" type="text"
value=""/>
<label for="apollo13-contact-subject">
<?php echo __('Subject', TPL_SLUG) ?>
</label>
</div>
</div>
<div style="clear: both;"></div>
<div<?php echo ($name_error ? ' class="error"' : '') ?>>
<textarea id="apollo13-contact-content" name="apollo13-contact-content" rows="10" cols="40"></textarea>
</div>
<div>
<input type="hidden" name="apollo13-contact-form" value="send"/>
<input id="contact-submit" type="submit" value="<?php echo __('Submit form', TPL_SLUG) ?>"/>
</div>
</form>
I really can't say for certain as I don't know where $subject gets its original value nor do I know what your html form looks like.
$subject = $site . __(' - message from contact form', TPL_SLUG);
Would possibly change to
$subject = $site . ' | ' . $subject;
And the $body would look like the following:
$body = __('Site: ', TPL_SLUG) . $site . "\n\n"
. __('Name: ', TPL_SLUG) . $name . "\n\n"
. __('Email: ', TPL_SLUG) . $email . "\n\n"
. __('Message: ', TPL_SLUG) . $content;

Categories