SMTP Server Email | Static HTML Page E-mail Sender PHP Using Gmail SMTP

SMTP Server Email Static HTML Page E-mail Sender PHP Using Gmail SMTP

Static HTML Page E-mail Sender PHP Using Gmail SMTP

How we can send an email utilizing Gmail SMTP server from a PHP page/script.
 SMTP is a shortened form of Simple Mail Transfer Protocol.
 SMTP is a web standard for electronic mail, i.e., email.
 All mail servers and other mail exchange specialists utilize SMTP to send and get emails.
 Firstly, we’ll investigate the PHP mailer library we’re going to use.
 You can take this library as a contrasting option to mail() work in PHP.
After that, we’ll talk about the procedure.

Some portion of what makes the PHP mail() function is so straightforward is its absence of adaptability. It’s baffling that stock PHP mail() does not ordinarily enable you to utilize the SMTP server of your decision, and it doesn’t support SMTP authentication —required by many mail servers.

Live Demo   Download Source Code

Index.php

<form method="post" id="contact-formc" class="form" role="form" novalidate="novalidate">
   <div class="form-group">    
      <input type="text" class="form-control" name="fcname" placeholder="Full Name *" required>
   </div>
   <div class="form-group">    
      <input type="text" class="form-control" name="fcemail" placeholder="Email *" required>
   </div>
   <div class="form-group">    
      <input type="text" class="form-control" name="fcwebsite" placeholder="Website" required>
   </div>
   <div class="form-group">
      <textarea rows="5" class="form-control" name="fccomment" placeholder="Your Message *" style="height:175px;" required></textarea>
   </div>
   <div id='message_post'></div>
   <input class="submit-detailss btn btn-default form-send" type='button' value='SUBMIT' name='submitf' id="submitf">
   <p class="success-messages" style="color: #149214; display:none;" ><i class="fa fa-check-circle contact-done-icon"></i> Sent Successfuly...</p>
   <p class="unsuccess-messages" style="color: #F00; display:none;" ><i class="fa fa-times-circle contact-done-icon"></i> Sending failed...</p>
</form>

mail.php

<?php
$to_address = "lisenmee@gmail.com";
$subject = "Customer Requirement";

$message = 'Full Name:'.$_POST['fcname'].'<br/> Email:'.$_POST['fcemail'].'<br/> Website:'.$_POST['fcwebsite'].'<br/> Message :'.$_POST['fccomment'].'<br/>';
			
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8 " . "\r\n";

// More headers
$headers .= "Reply-To: Lisenme <info@lisenme.com> \r\n";
$headers .= "Return-Path: Lisenme <info@lisenme.com> \r\n";
$headers .= "From: Lisenme <info@lisenme.com> \r\n";
$headers .= "Organization: Lisenme \r\n";
$headers .= "X-Sender: Lisenme <info@lisenme.com>  \r\n";
$headers .= "X-Mailer: PHP \r\n";

if(mail($to_address,$subject,$message,$headers,'-finfo@lisenme.com'))
    echo "1";
else
    echo "not done";
	
?>

Script.js

               $(document).on('click', '.submit-detailss', function(ev){
            if($("#contact-formc").valid() == true){
               var form_data = $("#contact-formc").serialize();
                   
                $.post('fsend_mail_con.php', form_data , function(data,status){
                    console.log(data);
                    if(data == 1){
                        $(".success-messages").show(200);
                        $(".unsuccess-messages").hide(200);
                    }
                    else{
            
                        $(".unsuccess-messages").show(200);
                        $(".success-messages").hide(200);
                    }
                }); 
              }
               });

 

 

You May Also Like

About the Author: Ranjith Kumar A

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x