PHP邮件/ HTML表单不发送

时间:2015-03-30 17:01:56

标签: php html

我之前使用过相同的脚本,它在同一台服务器上使用另一种形式,但由于某种原因,这次它不起作用,我无法弄清楚原因。

HTML表单:

<form method="post" action="#" class="dealer-form" enctype="multipart/form-data">
<input type="hidden" name="form-type" value="dealer">

    <p><label for="companyname"><span class="required">*</span> Company Name:</label> <input type="text" id="companyname" name="companyname" value="" class="form-control" required /></p>
    <p><label for="name"><span class="required">*</span> Your Name:</label> <input type="text" id="name" name="name" value="" class="form-control" required /></p>
    <p><label for="email"><span class="required">*</span> Email Address:</label> <input type="email"id="email" name="email" value="" class="form-control" required /></p>
    <p><label for="phone"><span class="required">*</span> Phone Number:</label> <input type="tel" id="phone" name="phone" value="" class="form-control" required /></p>
    <p><label for="position"><span class="required">*</span> Your Company Position:</label> <input type="text" id="position" name="position" value="" class="form-control" required /></p>
    <p><label for="street"><span class="required">*</span> Street Address:</label> <input type="text" id="street" name="street" value="" class="form-control" required /></p>
    <p><label for="city"><span class="required">*</span> City:</label> <input type="text" id="city" name="city" value="" class="form-control" required /></p>
    <p><label for="state"><span class="required">*</span> State:</label> <input type="text" id="state" name="state" value="" class="form-control" required /></p>
    <p><label for="zip"><span class="required">*</span> Zip:</label> <input type="text" id="zip" name="zip" value="" class="form-control" required /></p>

    <hr class="new" />

    <p><label for="fedtax">Federal Tax ID#:</label> <input type="text" id="fedtax" name="fedtax" value="" class="form-control" /></p>
    <p><label for="salestax">Sales Tax Permit # (If applicable for your state):</label> <input type="text" id="salestax" name="salestax" value="" class="form-control" /></p>
    <p><label for="license">Security Installer License # (If applicable for your state):</label> <input type="text" id="license" name="license" value="" class="form-control" /></p>

    <h4><span class="required">*</span> Is installing or reselling CCTV or Security Equipment your full time occupation?</h4>
    <p>
    <input name="occupation" value="Yes" type="radio" required />
    <span  class="lbl padding-8">Yes</span>
    </p>

    <p>
    <input name="occupation" value="No" type="radio" required />
    <span  class="lbl padding-8">No</span>
    </p>


    <h4><span class="required">*</span> How long have you been in the business of reselling or installing CCTV?</h4>
    <p>
    <input name="exp" value="Less than 1 year" type="radio" required />
    <span  class="lbl padding-8">Less than 1 Year</span>
    </p>

    <p>
    <input name="exp" value="1 to 5 Years" type="radio" required />
    <span  class="lbl padding-8">1 to 5 Years</span>
    </p>

    <p>
    <input name="exp" value="Over 5 Years" type="radio" required />
    <span  class="lbl padding-8">Over 5 Years</span>
    </p>

    <h4>Security License Certificates, Sales Tax Permits & Resellers Permit:</h4>
    <p><input type="file" id="upload" name="upload[]" multiple></p>

<input type="submit" name="submit" value="Submit Application">
</form>

以下是我在同一页面上包含的php:

if( isset($_POST['form-type']) ){

if( $_POST['form-type'] == 'dealer' ){

$to = 'myemail@mydomain.com';

$headers = "From: applications@mydomain.com" . "\r\n";
$headers .= "Reply-To:" . strip_tags($_POST['email']) . "\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";


   $companyname = trim(strip_tags($_POST['companyname']));
   $name = trim(strip_tags($_POST['name']));
   $email = trim(strip_tags($_POST['email']));
   $phone = trim(strip_tags($_POST['phone']));
   $position = trim(strip_tags($_POST['position']));
   $street = trim(strip_tags($_POST['street']));
   $city = trim(strip_tags($_POST['city']));
   $state = trim(strip_tags($_POST['state']));
   $zip = trim(strip_tags($_POST['zip']));
   $fedtax = trim(strip_tags($_POST['fedtax']));
   $salestax = trim(strip_tags($_POST['salestax']));
   $license = trim(strip_tags($_POST['license']));
   $occupation = trim(strip_tags($_POST['occupation']));
   $exp = trim(strip_tags($_POST['exp']));

    $body = "<html><body>";
    $body .= "<h3>Contact Information:</h3>";
    $body .= "<p><strong>Name:</strong> $name </p>";
    $body .= "<p><strong>Email:</strong> $email </p>";
    $body .= "<p><strong>Phone Number:</strong> $phone </p>";
    $body .= "<h3>Address:</h3>";
    $body .= "<p> $address <br/>";
    $body .= "$city, $state $zip </p>";

    $body .= "<h3>Company Information:</h3>";
    $body .= "<p><strong>Company Name:</strong> $companyname </p>";
    $body .= "<p><strong>Company Position:</strong> $position </p>";
    $body .= "<p><strong>Federal Tax ID#:</strong> $fedtax </p>";
    $body .= "<p><strong>Sales Tax Permit # (If Applicable):</strong> $sales </p>";
    $body .= "<p><strong>Security Installer License # (If Applicable):</strong> $license </p>";
    $body .= "<p><strong>Is installing or reselling CCTV or Security Equipment your full time occupation?</strong> $occupation </p>";
    $body .= "<p>I have <strong>$exp</strong> experience in the business of reselling or installing CCTV</p>";
    $body .= "</body></html>";

   $subject = "New Dealer Application";

}



mail($to, $subject, $body, $headers);
header('Location:  ' . $this->getUrl('dealers/success'));
exit();

}

0 个答案:

没有答案