无法使用php中的sendmail()从SMTP服务器发送邮件

时间:2016-12-28 13:30:41

标签: php phpmailer sendmail

我想从我的网站向客户发送邮件。我正在使用php sendmail()发送邮件。 以下是我的代码: -

<?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);  


}

&GT;

和Send_Mail.php文件如下所示:

<?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();   
}
?>

当我在服务器上传相同的代码时,它在localhost bt上工作,然后邮件没有发送。 任何配置设置需要更改或其他任何内容。 需要帮忙 .. 提前谢谢。

0 个答案:

没有答案