0

kindly help out on this where am I going Wrong

I have a website with a contact form the problem is when one send email from my website it show a success message but the message is not recieved on the other side.

this is is my code

   <?php
  require_once 'mailer/class.phpmailer.php'; 
  // creates object
  $mail = new PHPMailer(true); 
  if(isset($_POST['btn_send']))
  {
   $email      = strip_tags($_POST['email']);
   $subject    = strip_tags($_POST['subject']);
   $text_message    = "Hello";      
   $message  = strip_tags($_POST['message']);
 try
   {
    $mail->IsSMTP(); 
    $mail->isHTML(true);
    $mail->SMTPDebug  = 0;                     
    $mail->SMTPAuth   = true;                  
    $mail->SMTPSecure = "ssl";                 
    $mail->Host       = "smtp.gmail.com";      
    $mail->Port        = '465';             
    $mail->AddAddress($email);
    $mail->Username   ="myemail@gmail.com";  
    $mail->Password   ="myemailpassword";            
    $mail->SetFrom('myemail@gmail.com','STAMP');
    $mail->AddReplyTo("myemail@gmail.com","STAMP");
    $mail->Subject    = $subject;
    $mail->Body    = $message;
    $mail->AltBody    = $message;

    if($mail->Send())
    {

     $msg = "Hi, Your mail successfully sent to".$email." ";

    }
   }
   catch(phpmailerException $ex)
   {
    $msg = "<div class='alert alert-warning'>".$ex->errorMessage()."</div>";
   }
  } 


?> 



<form  method="post" action="">

<div class="form-group input-row">
  <label class="col-md-12 col-sm-12 col-xs-12"for="first_name">Email</label>
<div class="col-md-12 col-sm-12 col-xs-12">
  <input    class = "form-control" type="email" name="email">
</div>
</div>

<div class="form-group input-row">
  <label class="col-md-12 col-sm-12 col-xs-12"for="last_name">Subject</label>
<div class="col-md-12 col-sm-12 col-xs-12">
  <input class="form-control" type="text" name="subject" >
</div>
</div>

<div class="form-group input-row">
  <label class="col-md-12 col-sm-12 col-xs-12"for="first_name">Message</label>
<div class="col-md-12 col-sm-12 col-xs-12">
  <textarea class="form-control" name="message" maxlength="1000" cols="25" rows="6"></textarea>
</div>
</div>
<div class="form-group" style="text-align:center">
<label class="col-md-12 col-sm-12 col-xs-12"for="first_name"></label>
  <input type="submit" name="btn_send" class = "btn btn-primary" value="Send Message">  
</div>
</form>

Am expecting when the sender sends a Message it is sent successifully and the recepient recieves the message

0 Answers0