Mail not going through on live website running on php

I do have 2 pages one is contact-us.php and the other is gmail-confi.php, both scripts are working for the other one live website but not for the website I want it to work. Can somebody help?

I just want the client to fill the contact form and submit it so that I can receive it in my Gmail inbox but the script is not working. after submission, the next page is showing a blank page,i don't know why gmail-confi.php is not working. please help

here is page gmail-confi.php

         <?php
            //gmail-confi.php
                  require_once('config.php');
                    require_once('session.php');



         //contact us page form configure
        if(isset($_POST['contactus_page_submit']))
         {
            $name=$_POST['name'];
             $fromemail =$_POST['email'];
              $subject=$_POST['subject'];
              $phone=$_POST['phone'];
                $msg=$_POST['messege'];
    
                $header = "From : " . $fromemail . "\r\n";
                 $header .= "X-Mailer: PHP /" . phpversion() . "\r\n";
                 $header .= "MIME-Version: 1.0" . "\r\n";
                $header .= "Content-Type: text/html; charset=ISO-8859-1 \r\n";
    
                $messege= "<html> <body>";
                $messege .= "<p>Name: " . $name . "</p>";
                $messege .= "<p>Email: ". $fromemail . "</p>";
                $messege .= "<p>Contact Number: ". $phone . "</p>";
                $messege .= "<p>Message: " . $msg. "</p>";
                $messege .= "</body></html>";
                 $to ="random.random@gmail.com";
    
                   if(mail($to, $subject, $messege, $header))
                    {
                    echo '<script type="text/javascript">alert("Form has been successfully submitted. 
                     Thank you.")</script>';
                    echo '<script type="text/javascript">location.replace("contactus.php")</script>';
                        }
                         else{
                    //echo '<script type="text/javascript">alert("Sorry Please Try After Some Time.") 
                    </script>';
                    //echo '<script type="text/javascript">location.replace("contactus.php") 
                      </script>';
                    }
                }
    
                ?>

here is another page contact-us.php

         <?php 
              //contactus
                require_once ('header.php');
                      ?>
                      <section id="contact-page" class="pt-90 pb-120 gray-bg">
                         <div class="container">
                          <div class="row">
                         <div class="col-md-7" style="margin-top: 171px;">
                           <div class="contact-from mt-30">
                               <div class="section-title">
                                  <h5>Contact Us</h5>
                                <h2>Keep in touch</h2>
                             </div> <!-- section title -->
                        <div class="main-form pt-45">
                        <form  action="gmail-confi.php" method="post" data-toggle="validator">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="singel-form form-group">
                                        <input name="name" type="text" placeholder="Your name" data- 
                            error="Name is required." required="required">
                                        <div class="help-block with-errors"></div>
                                    </div> <!-- singel form -->
                                </div>
                                <div class="col-md-6">
                                    <div class="singel-form form-group">
                                        <input name="email" type="email" placeholder="Email" data- 
                        error="Valid email is required." required="required">
                                        <div class="help-block with-errors"></div>
                                    </div> <!-- singel form -->
                                </div>
                                <div class="col-md-6">
                                    <div class="singel-form form-group">
                                        <input name="subject" type="text" placeholder="Subject" data- 
                          error="Subject is required." required="required">
                                        <div class="help-block with-errors"></div>
                                    </div> <!-- singel form --> 
                                </div>
                                <div class="col-md-6">
                                    <div class="singel-form form-group">
                                        <input name="phone" type="text" placeholder="Phone" data- 
            error="Phone is required." required="required">
                                        <div class="help-block with-errors"></div>
                                    </div> <!-- singel form -->
                                </div>
                                <div class="col-md-12">
                                    <div class="singel-form form-group">
                                        <textarea name="messege" placeholder="Messege" data- 
                    error="Please,leave us a message." required="required"></textarea>
                                        <div class="help-block with-errors"></div>
                                    </div> <!-- singel form -->
                                </div>
                                <div class="col-md-12">
                                    <div class="singel-form">
                                        <button type="submit" name="contactus_page_submit" 
                     class="main-btn">Send</button>
                                    </div> <!-- singel form -->
                                </div> 
                            </div> <!-- row -->
                        </form>
                        </div> <!-- main form -->
                     </div> <!--  contact from -->
                     </div>
                  <!-- Contact Address -->
                   <div class="col-md-5" style="margin-top: 171px;">
                    <h4 class="cs-section-title-lg">Contact Details</h4>
                       <!--  Icon Text -->
                      <div class="cs-icon-text">
                      <div class="media-left">
                    <i class="fa fa-map-marker cs-icon"></i>
                      </div>
                     <div class="media-body">
                         <p>random random random random random</p>
                          <p>randomrandomrandomrandomrandomrandom</p>
                          <p>randomrandomrandomrandomrandomrandom</p>
                         </div>
                         </div>
                     <!-- Icon Text  -->
                      <!--  Icon Text -->
                         <div class="cs-icon-text">
                           <div class="media-left">
                           <i class="fa fa-phone cs-icon"></i>
                         </div>
                          <div class="media-body">
                             <p>232222222222222222222222</p>
                           </div>
                         </div>
                      <div class="cs-icon-text">
                       <div class="media-left">
                            <i class="fa fa-envelope cs-icon"></i>
                        </div>
                        <div class="media-body">
                           <p>eeeeeeeeee</p>
                            <p>rrrrrrrrrrrrrrr</p>
                             </div>
                              </div> 
                          <!-- Icon Text  -->
                              </div>
                          </div> <!-- row -->
                          </div> <!-- container -->
                              </section>
                            <?php 
                            require_once ('footer.php');
                             ?>


Read more here: https://stackoverflow.com/questions/66997629/mail-not-going-through-on-live-website-running-on-php

Content Attribution

This content was originally published by aryan joshi at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: