0

送信されると自動応答を送信するphp連絡フォームがあります。私たちが抱えている問題は、受信者が @aol.com の場合、AOL にスパムとして報告されることです。@aol.com アドレスのみの自動応答を無効にしたいと考えています。

<?php
//Collect contact form data
//Check Special Field
//Email ASC & Webmaster
//Email Sender
//Redirect to thank you page

require_once($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php');

/********  CONTACT DATA **********/
$name = stripslashes($_POST['name']);
$company = stripslashes($_POST['company']);
$address = stripslashes($_POST['address']);
$city = stripslashes($_POST['city']);
$state = stripslashes($_POST['state']);
$zipcode = stripslashes($_POST['zipcode']);
$country = stripslashes($_POST['country']);
$website = $_POST['website'];
$phone = stripslashes($_POST['phone']);
$fax = stripslashes($_POST['fax']);
$email = stripslashes($_POST['contact']);
$Referred = stripslashes($_POST['referred']);
 $CustomerType = stripslashes($_POST['CustomerType']);
 $Comments = stripslashes($_POST['comments']);


 /********  CHECK SPECIAL FIELD **********/
 $spamcheck = stripslashes($_POST['email']);

//if spamcheck is blank complete page
 if ($spamcheck=="") {


/********  EMAIL ASC & WEBMASTER  **********/
$message = "
-----------------------------------------------------------------------------
   Information Inquiry
-----------------------------------------------------------------------------

$name has visited the Coastal web site and would like some information.
The details they entered on the website are:

Name: $name
Company: $company
Address: $address
City: $city
State: $state
Zip Code: $zipcode
Country: $country
Website: $website
Phone: $phone
Fax: $fax
Email: $email

Referred to web site: $Referred

CustomerType: $CustomerType

Comments: $Comments

Kind Regards,
Coastal Pet Products, Inc.
http://www.coastalpet.com
";   
 $email_address = "ashley.brindle@coastalpet.com, robert.kendall@coastalpet.com,    heather.hartman@coastalpet.com";    

$subject = "Information Inquiry";
$headers = "From: $name <$email>";
$message = str_replace("\r",'',$message); //fixes postfix php bug that double spaces messages





/********  EMAIL SENDER **********/
$message2 = "
-----------------------------------------------------------------------------
  Re: Information Inquiry
-----------------------------------------------------------------------------

Thank you $name for visiting the Coastal Pet Products web site. We will be using the details you entered to contact you.

Name: $name
Company: $company
Address: $address
City: $city
State: $state
Zip Code: $zipcode
Country: $country
Website: $website
Phone: $phone
Fax: $fax
Email: $email

Referred to web site: $Referred

CustomerType: $CustomerType

Comments: $Comments

Kind Regards,
Coastal Pet Products, Inc
http://www.coastalpet.com
";   
$email_address2 = "$email";         
$subject2 = "Re: Information Inquiry";
$headers2 = "From: Coastal Pet Products <ashley.brindle@coastalpet.com>";
$message2 = str_replace("\r",'',$message2); //fixes postfix php bug that double spaces messages

    //send message 1 and save result in success var (either true for success,
// or false for fail
$success = mail(mail($email_address2, $subject2, $message, $headers2) && mail($email_address, $subject, $message, $headers))

//conditionaly send message2, no need to check success on this one
if (strpos($email,'@aol.com') == false) {
mail(mail($email_address2, $subject2, $message2, $headers2) && mail($email_address,   $subject, $message, $headers))
}

if ($success){
//show success message
 success
}
else{
//fail message
fail
}


?>
      <h3>Thank you for your interest in Coastal Pet Products!</h3>
      <p>If you have asked us to contact you, we will be using the information you provided. We thank you for taking the time to help us be a better company.</p>   

<?php } else { ?>
    <p>There was a problem submitting your information.  Please try again.</p>
    <p>If you continue to have problems, please contact Customer Service at 1-800-321-0248.</p>


<?php } 



?>
4

2 に答える 2

0
if (strpos($email,'@aol.com') == false) {
    //send auto response
}

明確にするために:

//send message 1 and save result in success var (either true for success,
// or false for fail
$success = mail($message1 <SNIP>...

//conditionaly send message2, no need to check success on this one
if (strpos($email,'@aol.com') == false) {
    mail($message2 <SNIP>...
}

if ($success){
//show success message
}else{
//fail message
}

EDIT 2 わかりました。PHP に関する優れた本を読む必要があると思います。WROX の本は通常、よく書かれています。また、まともな IDE を使用すると、より明白なエラーが強調表示されます。JetBrains の php ストームは素晴らしいです。支払いたくない場合は、netbeans がかなり良いです。

そうは言っても、ここでコードをクリーンアップしました:

<?php
    //Collect contact form data
    //Check Special Field
    //Email ASC & Webmaster
    //Email Sender
    //Redirect to thank you page

    require_once($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php');

    /********  CONTACT DATA **********/
    $name = stripslashes($_POST['name']);
    $company = stripslashes($_POST['company']);
    $address = stripslashes($_POST['address']);
    $city = stripslashes($_POST['city']);
    $state = stripslashes($_POST['state']);
    $zipcode = stripslashes($_POST['zipcode']);
    $country = stripslashes($_POST['country']);
    $website = $_POST['website'];
    $phone = stripslashes($_POST['phone']);
    $fax = stripslashes($_POST['fax']);
    $email = stripslashes($_POST['contact']);
    $Referred = stripslashes($_POST['referred']);
    $CustomerType = stripslashes($_POST['CustomerType']);
    $Comments = stripslashes($_POST['comments']);


    /********  CHECK SPECIAL FIELD **********/
    $spamcheck = stripslashes($_POST['email']);

    //if spamcheck isnt blank exit page, no need for error message to user, as its a spam bot
    if ($spamcheck!=="") {

        exit;

    }


        /********  EMAIL ASC & WEBMASTER  **********/
        $message = "
    -----------------------------------------------------------------------------
       Information Inquiry
    -----------------------------------------------------------------------------

    $name has visited the Coastal web site and would like some information.
    The details they entered on the website are:

    Name: $name
    Company: $company
    Address: $address
    City: $city
    State: $state
    Zip Code: $zipcode
    Country: $country
    Website: $website
    Phone: $phone
    Fax: $fax
    Email: $email

    Referred to web site: $Referred

    CustomerType: $CustomerType

    Comments: $Comments

    Kind Regards,
    Coastal Pet Products, Inc.
    http://www.coastalpet.com
    ";
        $email_address = "ashley.brindle@coastalpet.com, robert.kendall@coastalpet.com,    heather.hartman@coastalpet.com";

        $subject = "Information Inquiry";
        $headers = "From: $name <$email>";
        $message = str_replace("\r",'',$message); //fixes postfix php bug that double spaces messages





        /********  EMAIL SENDER **********/
        $message2 = "
    -----------------------------------------------------------------------------
      Re: Information Inquiry
    -----------------------------------------------------------------------------

    Thank you $name for visiting the Coastal Pet Products web site. We will be using the details you entered to contact you.

    Name: $name
    Company: $company
    Address: $address
    City: $city
    State: $state
    Zip Code: $zipcode
    Country: $country
    Website: $website
    Phone: $phone
    Fax: $fax
    Email: $email

    Referred to web site: $Referred

    CustomerType: $CustomerType

    Comments: $Comments

    Kind Regards,
    Coastal Pet Products, Inc
    http://www.coastalpet.com
    ";
        $email_address2 = "$email";
        $subject2 = "Re: Information Inquiry";
        $headers2 = "From: Coastal Pet Products <ashley.brindle@coastalpet.com>";
        $message2 = str_replace("\r",'',$message2); //fixes postfix php bug that double spaces messages

    //send message 1 and save result in success var (either true for success, or false for fail
    $success = mail($email_address, $subject, $message, $headers);

    //conditionally send message2, no need to check success on this one
    if (strpos($email,'@aol.com') == false) {
        mail($email_address2, $subject2, $message2, $headers2);
    }

    if ($success):?>
          <h3>Thank you for your interest in Coastal Pet Products!</h3>
          <p>If you have asked us to contact you, we will be using the information you provided. We thank you for taking the time to help us be a better company.</p>

    <?php else:?>

        <p>There was a problem submitting your information.  Please try again.</p>
        <p>If you continue to have problems, please contact Customer Service at 1-800-321-0248.</p>
    <?php endif;?>

これは確認していませんが、問題ないはずです。

于 2013-09-17T20:27:52.413 に答える
0

メールを送信するスクリプトを次のように変更する必要があります。

$noResponceDomains = array("aol.com", "more.domain"); // recommended to make a separate config
$domain = end((explode("@", $email))); // $email - user's email
if(!in_array($domain, $noResponceDomains)){
    // send you mail
}
于 2013-09-17T20:27:54.340 に答える