PHP mail function sends to Gmail but not to some other domains

  Kiến thức lập trình

I have php mail() implemented but it sends only to gmail not to other servers. I have multiple recipient on mail code.

I want that it should send mails to the given recipient. I have below code and that is not sending mail to my recipients.

<?php
    if ($_SERVER["REQUEST_METHOD"] == "POST") {

        // set recipient email address 
        $to = "[email protected], [email protected], [email protected]";
    
        // set email subject 
        $subject = "New Form Submission";
    
        // compose email
        $message = '<html><body>';
        $message .= '<h2>Do I qualify Form Submission</h2>';
        $message .= '<p><strong>First Name:</strong> ' . $_POST["firstName"] . '</p>';
        $message .= '<p><strong>Last Name:</strong> ' . $_POST["lastName"] . '</p>';
        $message .= '<p><strong>City:</strong> ' . $_POST["city"] . '</p>';
        $message .= '<p><strong>Country:</strong> ' . $_POST["country"] . '</p>';
        $message .= '<p><strong>Citizenship:</strong> ' . $_POST["citizenship"] . '</p>';
        $message .= '<p><strong>Age:</strong> ' . $_POST["age"] . '</p>';
        $message .= '<p><strong>Mobile:</strong> ' . $_POST["mobile"] . '</p>';
        $message .= '<p><strong>Email:</strong> ' . $_POST["emailInfo"] . '</p>';
        $message .= '<p><strong>Notes:</strong> ' . $_POST["notes"] . '</p>';
        $message .= '<p><strong>Information Regarding:</strong> ' . $_POST["informationRegarding"] . '</p>';
        $message .= '</body></html>';

        $headers = 'MIME-Version: 1.0' . "rn";
        $headers .= 'Content-type: text/html; charset=utf-8' . "rn";
        $headers .= 'From: ' . $_POST['emailInfo'] . "rn";
        $headers .= 'Reply-To: [email protected]' . "rn";
        $headers .= 'Cc: [email protected]' . "rn";
        $headers .= 'X-Mailer: PHP/' . phpversion();
    
        // send email
        $success = mail($to, $subject, $message, $headers);

        if (!$success) {
            echo "Email sending failed";
            echo "Error: " . error_get_last()['message'];
        }
    }
?>

LEAVE A COMMENT