Auto Responder

Issues related to forms.
Post Reply
curtis@phantech.com
 
 
Posts: 4
Joined: Fri Oct 19, 2018 8:27 pm

Auto Responder

Post by curtis@phantech.com » Fri Oct 19, 2018 8:35 pm

Enabling Auto Responder sends out 2 emails. How do I change that to only send 1 email?

User avatar
Pablo
 
Posts: 14099
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: Auto Responder

Post by Pablo » Sat Oct 20, 2018 7:12 am

This is most likely caused by conflicting settings or multiple forms on the same page.
What exactly did you do?
What are you settings?
What is the generated PHP code?

curtis@phantech.com
 
 
Posts: 4
Joined: Fri Oct 19, 2018 8:27 pm

Re: Auto Responder

Post by curtis@phantech.com » Sat Oct 20, 2018 5:49 pm

I get 2 emails. One from you my page the other from my ISP

User avatar
Pablo
 
Posts: 14099
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: Auto Responder

Post by Pablo » Sat Oct 20, 2018 5:57 pm

To be able to help you I need more details.
Can you please answer those questions?
- What exactly did you do?
- What are your exact settings?
- What is the generated PHP code (Page HTML)?

or else:
viewtopic.php?f=10&t=82134

curtis@phantech.com
 
 
Posts: 4
Joined: Fri Oct 19, 2018 8:27 pm

Re: Auto Responder

Post by curtis@phantech.com » Sun Oct 21, 2018 4:25 pm

<?php
function ValidateEmail($email)
{
$pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
return preg_match($pattern, $email);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['formid']) && $_POST['formid'] == 'form2')
{
$mailto = 'support@phantech.com';
$mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
$subject = 'Message from InfoRecall Contact ';
$message = 'A Contact Message from InfoRecall';
$success_url = './sent.html';
$error_url = './problem.html';
$error = '';
$autoresponder_from = 'PhantechSoftware';
$autoresponder_to = isset($_POST['email']) ? $_POST['email'] : $mailfrom;
$autoresponder_subject = 'Message from Phantech Software';
$autoresponder_message = 'Thanks for contacting us. We\'ll respond as soon as possible. Your satisfaction is important to us.
';
$eol = "\n";
$boundary = md5(uniqid(time()));
$header = 'From: '.$mailfrom.$eol;
$header .= 'Reply-To: '.$mailfrom.$eol;
$header .= 'MIME-Version: 1.0'.$eol;
$header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
$header .= 'X-Mailer: PHP v'.phpversion().$eol;
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address is invalid!\n<br>";
}
if (!empty($error))
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $error, $errorcode);
echo $errorcode;
exit;
}
$internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response");
$message .= $eol;
$message .= "IP Address : ";
$message .= $_SERVER['REMOTE_ADDR'];
$message .= $eol;
$logdata = '';
foreach ($_POST as $key => $value)
{
if (!in_array(strtolower($key), $internalfields))
{
if (!is_array($value))
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
}
else
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
}
}
}
$body = 'This is a multi-part message in MIME format.'.$eol.$eol;
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
$body .= 'Content-Transfer-Encoding: 8bit'.$eol;
$body .= $eol.stripslashes($message).$eol;
if (!empty($_FILES))
{
foreach ($_FILES as $key => $value)
{
if ($_FILES[$key]['error'] == 0)
{
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
$body .= 'Content-Transfer-Encoding: base64'.$eol;
$body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
$body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
}
}
}
$body .= '--'.$boundary.'--'.$eol;
if ($mailto != '')
{
mail($mailto, $subject, $body, $header);
}
$autoresponder_header = 'From: '.$autoresponder_from.$eol;
$autoresponder_header .= 'Reply-To: '.$autoresponder_from.$eol;
$autoresponder_header .= 'MIME-Version: 1.0'.$eol;
$autoresponder_header .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
$autoresponder_header .= 'Content-Transfer-Encoding: 8bit'.$eol;
$autoresponder_header .= 'X-Mailer: PHP v'.phpversion().$eol;
foreach ($_POST as $key => $value)
{
if (!in_array(strtolower($key), $internalfields))
{
if (!is_array($value))
{
$autoresponder_message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
}
else
{
$autoresponder_message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
}
}
}
mail($autoresponder_to, $autoresponder_subject, $autoresponder_message, $autoresponder_header);
header('Location: '.$success_url);
exit;
}
?>

User avatar
Pablo
 
Posts: 14099
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: Auto Responder

Post by Pablo » Sun Oct 21, 2018 5:28 pm

The code is correct, only one email is sent by the auto responder script.
Note however that the email is also set to 'support@phantech.com', so if you use the same email for testing then you will receive two emails.

curtis@phantech.com
 
 
Posts: 4
Joined: Fri Oct 19, 2018 8:27 pm

Re: Auto Responder

Post by curtis@phantech.com » Mon Oct 22, 2018 12:16 am

I'm plenty dumb!

Note however that the email is also set to 'support@phantech.com', so if you use the same email for testing then you will receive two emails.

That's exactly what I did.

Thanks for pointing it out.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests