Send Mail Using Php 💌💌💌


Send-Mail-Using-Php


Copy & Paste this code in your project

<!DOCTYPE html>
<html>
   <head>
      <title>Mail</title>
      <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
   </head>
   <body>
      <div class="container border border-warning">
         <h1 class="text-center text-primary">Send Mail using PHP mail() function</h1>
         <form method="post">
            name:<input type="text" name="name" class="form-control" placeholder="Enter name"><br>
            Sub:<input type="text" name="sub"  class="form-control" placeholder="Enter subject"><br>
            Email:<input type="email" name="email" class="form-control" placeholder="Enter email"><br>
            MObile:<input type="text" name="mobile" class="form-control" placeholder="Enter mobile"><br>
            Message:<textarea name="message" rows="5" cols="30" class="form-control" placeholder="Enter message"></textarea>
            <br>
            <input type="submit" name="submit" class="btn btn-success" value="send">
         </form>
      </div>
      <?php
         if(isset($_POST['submit']))
         {
             $to="abc@gmail.com";//receiver address
       
             $name=$_POST['name'];
             $sender_email=$_POST['email'];
             $sub=$_POST['sub'];
             $mobile=$_POST['mobile'];
             $message=$_POST['message'];
       
           
                  
                    $all="Name:".$name."<br>"."Subject:".$sub."<br>"."Mobile:".$mobile."<br>"."Message:".$message;
       
                    $header = "From:".$sender_email."\r\n";
                          $header .= "MIME-Version: 1.0 \r\n";
                          $header .= "Content-type: text/html;charset=UTF-8 \r\n";
       
             $result = mail ($to,$sub,$all,$header);
       
                          if( $result == true )
                          {
                             $response="Message sent successfully...";
                          }
                          else
                          {
                             $response= "Sorry, unable to send mail...";
                          }
         }
       
       
       
         ?>
      <div class="alert alert-warning alert-dismissible fade show" role="alert">
         <strong></strong> <?php if(isset($response)) echo $response; ?>
         <button type="button" class="close" data-dismiss="alert" aria-label="Close">
         <span aria-hidden="true">&times;</span>
         </button>
      </div>
      <!-- jQuery library -->
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
      <!-- Popper JS -->
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
      <!-- Latest compiled JavaScript -->
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
   </body>
</html>

NOTE : वर दिलेला code फक्त live website वरच रन होईल 

Post a Comment

2 Comments

Comment Rules :

1. Do not post Adult/illegal Links.
2. Try to comment in only मराठी / English Language.
3. Do not post other website's links which are useless.
4. Your Comment should be based on the Topic for other queries.
5. Do not use Abusive Language.
6. Respect each other.
Thank You for following the rules. Please Comment....