简体   繁体   中英

PHPmailer not sending mail in only Firefox

I'm having a bit of an issue with my PHPmailer service. I've tested it multiple times in Internet Explorer and Chrome. It works great. It just doesn't send anything when I try Firefox.

My domain shows it has PTR set up as well. I've checked the logs, and I've gotten no problems. Kind of at a loss for what to do.

HTML:

<div class = "myBox" ng-show="isSet(3)" ng-controller="ContactController">


<!-- Name, Company, Title, Address, City, State, County, Phone, Email, Type of request(new equipment or other pics), select one(item), comments -->
    <h2 class="topProductTitle"><b>Request a Quote:</b></h2><br>
    <form ng-submit="submit(contactform)" name="contactform" method="post" action="" class="form-horizontal" role="form">
        <div class="form-group" ng-class="{ 'has-error': contactform.inputName.$invalid && submitted }">
            <label for="inputName" class="col-lg-2 control-label">Name</label>
            <div class="col-lg-10">
                <input ng-model="formData.inputName" type="text" class="form-control" id="inputName" name="inputName" placeholder="Name" maxlength="25" required>
            </div>
        </div>
        <div class="form-group" ng-class="{ 'has-error': contactform.inputCompany.$invalid && submitted }">
            <label for="inputCompany" class="col-lg-2 control-label">Company</label>
            <div class="col-lg-10">
                <input ng-model="formData.inputCompany" type="text" class="form-control" id="inputCompany" name="inputCompany" placeholder="Company" maxlength="25" required>
            </div>
        </div>
        <div class="form-group" ng-class="{ 'has-error': contactform.inputTitle.$invalid && submitted }">
            <label for="inputTitle" class="col-lg-2 control-label">Title</label>
            <div class="col-lg-10">
                <input ng-model="formData.inputTitle" type="text" class="form-control" id="inputTitle" name="inputTitle" placeholder="Title" maxlength="25" required>
            </div>
        </div>
        <div class="form-group" ng-class="{ 'has-error': contactform.inputAddress.$invalid && submitted }">
            <label for="inputAddress" class="col-lg-2 control-label">Address</label>
            <div class="col-lg-10">
                <input ng-model="formData.inputAddress" type="text" class="form-control" id="inputAddress" name="inputAddress" placeholder="Address" maxlength="40" required>
            </div>
        </div>
        <div class="form-group" ng-class="{ 'has-error': contactform.inputCity.$invalid && submitted }">
            <label for="inputCity" class="col-lg-2 control-label">City</label>
            <div class="col-lg-10">
                <input ng-model="formData.inputCity" type="text" class="form-control" id="inputCity" name="inputCity" placeholder="City" maxlength="25" required>
            </div>
        </div>
        <div class="form-group" ng-class="{ 'has-error': contactform.inputState.$invalid && submitted }">
            <label for="inputState" class="col-lg-2 control-label">State</label>
            <div class="col-lg-10">
                <input ng-model="formData.inputState" type="text" class="form-control" id="inputState" name="inputState" placeholder="State" maxlength="25" required>
            </div>
        </div>
        <div class="form-group" ng-class="{ 'has-error': contactform.inputPhone.$invalid && submitted }">
            <label for="inputPhone" class="col-lg-2 control-label">Phone</label>
            <div class="col-lg-10">
                <input ng-model="formData.inputPhone" type="tel" class="form-control" id="inputPhone" name="inputPhone" placeholder="Phone" maxlength="15" required>
            </div>
        </div>
        <div class="form-group" ng-class="{ 'has-error': contactform.inputEmail.$invalid && submitted }">
            <label for="inputEmail" class="col-lg-2 control-label">Email</label>
            <div class="col-lg-10">
                <input ng-model="formData.inputEmail" type="email" class="form-control" id="inputEmail" name="inputEmail" placeholder="Email" maxlength="25" required>
            </div>
        </div>
        <div class="form-group" ng-class="{ 'has-error': contactform.inputSubject.$invalid && submitted }">
            <label for="inputSubject" class="col-lg-2 control-label">Subject</label>
            <div class="col-lg-10">
                <input ng-model="formData.inputSubject" type="text" class="form-control" id="inputSubject" name="inputSubject" placeholder="Subject Message" maxlength="25" required>
            </div>
        </div>
        <div class="form-group" ng-class="{ 'has-error': contactform.inputMessage.$invalid && submitted }">
            <label for="inputMessage" class="col-lg-2 control-label">Message</label>
            <div class="col-lg-10">
                <textarea ng-model="formData.inputMessage" class="form-control" rows="4" id="inputMessage" name="inputMessage" placeholder="Your message..." required></textarea>
            </div>
        </div>
        <div class="form-group">
            <div class="col-lg-offset-2 col-lg-10">
                <button type="submit" class="btn btn-primary btn-md" ng-disabled="submitButtonDisabled">
                    <h4>Send Message</h4>
                </button>
            </div>
        </div>
    </form>
</div>

Angular:

app.controller('ContactController', function ($scope, $http) {
    $scope.result = 'hidden'
    $scope.resultMessage;
    $scope.formData; //formData is an object holding the data.
    $scope.submitButtonDisabled = false;
    $scope.submitted = false; //used so that form errors are shown only after the form has been submitted
    $scope.submit = function(contactform) 
    {
        $scope.submitted = true;
        $scope.submitButtonDisabled = true;
        if (contactform.$valid) {
            $http({
                method  : 'POST',
                url     : 'contact-form.php',
                data    : $.param($scope.formData),  //param method from jQuery
                headers : { 'Content-Type': 'application/x-www-form-urlencoded' }  //set the headers so angular passing info as form data (not request payload)
            }).success(function(data){
                console.log(data);
                if (data.success) { //success comes from the return json object
                    $scope.submitButtonDisabled = true;
                    $scope.resultMessage = data.message;
                    $scope.result='bg-success';
                } else {
                    $scope.submitButtonDisabled = false;
                    $scope.resultMessage = data.message;
                    $scope.result='bg-danger';
                }
            });
        } else {
            $scope.submitButtonDisabled = false;
            $scope.resultMessage = 'Failed! Please fill out all the fields.';
            $scope.result='bg-danger';
        }
    }
});

PHP:

<?php
require_once 'PHPMailer-master/PHPMailerAutoload.php';

if (isset($_POST['inputName']) && isset($_POST['inputEmail']) && isset($_POST['inputSubject']) && isset($_POST['inputMessage'])) {

    //check if any of the inputs are empty
    if (empty($_POST['inputName']) || empty($_POST['inputEmail']) || empty($_POST['inputSubject']) || empty($_POST['inputMessage'])) {
        $data = array('success' => false, 'message' => 'Please fill out the form completely.');
        echo json_encode($data);
        exit;
    }

    //create an instance of PHPMailer
    $mail = new PHPMailer();
    $mail->From = $_POST['inputEmail'];
    $mail->FromName = $_POST['inputName'];
    $mail->AddAddress('test2@gmail.com'); //recipient 
    $mail->Subject = $_POST['inputSubject'];
    $mail->Body = "Name: " . $_POST['inputName'] . "\r\n\r\nCompany: " . stripslashes($_POST['inputCompany']) ."\r\n\r\nTitle: " . stripslashes($_POST['inputTitle']) . "\r\n\r\nAddress: " . stripslashes($_POST['inputAddress'])
    . "\r\n\r\nCity: " . stripslashes($_POST['inputCity']) . "\r\n\r\nState: " . stripslashes($_POST['inputState']) . "\r\n\r\nPhone: " . stripslashes($_POST['inputPhone']) . "\r\n\r\nEmail: " . stripslashes($_POST['inputEmail'])
    . "\r\n\r\nMessage: " . stripslashes($_POST['inputMessage']);

    $mail->isSMTP();
    $mail->Host = gethostbyname('smtp.gmail.com');
    $mail->Port = 587;
    $mail->SMTPDebug  = 1;
    $mail->SMTPSecure = "tls";
    $mail->SMTPAuth = true;
    $mail->Username = "Test@gmail.com";
    $mail->Password = "123";
    $mail->setFrom('Test@gmail.com', 'Contact Form');

    if (isset($_POST['ref'])) {
        $mail->Body .= "\r\n\r\nRef: " . $_POST['ref'];
    }

    if(!$mail->send()) {
        $data = array('success' => false, 'message' => 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo);
        echo json_encode($data);
        exit();
    }
        $data = array('success' => true, 'message' => 'Thanks! We have received your message.');
        echo json_encode($data);

} else {

    $data = array('success' => false, 'message' => 'Please fill out the form completely.');
    echo json_encode($data);

}

I have exactly the same thing. My mailer works with Chrome and Edge, but not Firefox. This cut-down code, called from the address bar, behaves the same:

$subject="FIREFOX test";
$scrnmess = "Howdee doodee";
$email="canthaveit.com";    
$recipient="webmaster@waterfowl.org.uk";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: " . $email . "\r\n";

mail($recipient, $subject, $scrnmess, $headers);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM