1

i want to send mail to the client from my site. i am using php sendmail() to send mail. following is my code :-

<?php
include('Connection.php');
include 'smtp/Send_Mail.php';
   if(isset($_POST['submit']))
{
    $name = $_POST['userName'];
    $mob = $_POST['mobileNo'];
    $email = $_POST['emailId'];
    $fed = $_POST['feedback'];

    $_SESSION['unm']=$name; 
    $_SESSION['mbl']=$mob;
    $_SESSION['eml']=$email;
    $_SESSION['fdbk']=$fed;

    $sql=" Call addUser('$name','$email','$mob','$fed')";
    $result = mysql_query($sql);

    $to=$email;
    $subject="Thank you for getting in touch.";
    $body=' <h1 style="color:blue;"> Dear '. $name.', </h1> <br/>           
                    Thank you for getting in touch';

        Send_Mail($to,$subject,$body);  


}

?>

and the Send_Mail.php file look like this:

<?php
function Send_Mail($to,$subject,$body)
{
    require 'class.phpmailer.php';
    $from = "ashmeerafurnishingxxx@gmail.com"; 
    $mail       = new PHPMailer();
    $mail->IsSMTP(true);            // use SMTP
    $mail->IsHTML(true);
    $mail->SMTPAuth   = true;             // enable SMTP authentication
    $mail->Host = "tls://smtp.gmail.com"; // Amazon SES server, note   "tls://" protocol
    $mail->Port =  465;                    // set the SMTP port
    $mail->Username   = "ashmeerafurnishingxxx@gmail.com";  // SMTP  username
    $mail->Password   = "xxxxxxx";  // SMTP password
    $mail->SetFrom($from, 'Ashmeera Furnishing Decor');
    $mail->AddReplyTo($from,'Ashmeera Furnishing Decor');
    $mail->Subject    = $subject;
    $mail->MsgHTML($body);
    $address = $to;
    $mail->AddAddress($address, $to);
    $mail->Send();   
}
?>

Its working on localhost bt when i upload the same code on server then the mail was not send. any configuration settings change required or anything else. need help .. thank in advance.

suresh
  • 33
  • 5
  • Your host allows SMTP? – Jimmy Adaro Dec 28 '16 at 13:37
  • what is the error? – Veshraj Joshi Dec 28 '16 at 13:50
  • Please search before posting, base your code on [the examples supplied with PHPMailer](https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps), and (especially importantly today) [use the latest version](https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps). – Synchro Dec 28 '16 at 13:54
  • 1
    Possible duplicate of [send email using Gmail SMTP server through PHP Mailer](http://stackoverflow.com/questions/16048347/send-email-using-gmail-smtp-server-through-php-mailer) – Synchro Dec 28 '16 at 13:54

0 Answers0