dtbsezxw28056 2015-03-07 09:07
浏览 23
已采纳

PHPMailer不发送

I am trying to create a contact form using PHP mailer.. it shows no error but I do not receive the email. I also tried to use the mail() function but it also not working..

Here's my PHP code

<?php

if (!empty($_POST['email']) && !empty($_POST['message'])){
$errors = array();
$to = "kim@t-i-c.asia";
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$body = $_POST['message'];
$headers  = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$headers .= "From:".$email;

    require_once 'phpmailer/class.phpmailer.php';
    $mail = new PHPMailer();
    // Set UP SMTP
    $mail->IsSMTP();
    $mail->SMTPAuth = true;
    $mail->SMTPSecure ='ssl';
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 465;
    $mail->Encoding = '7bit';

    //Authentication
    $mail->Username = "kuyakimpoy010@gmail.com";
    $mail->Password = "password";

    // Compose
    $mail->SetFrom ("client@t-i-c.asia", $email);
    $mail->AddReplyTo("client@t-i-c.asia", $email);
    $mail->Subject = $subject;
    $mail->MsgHtml($body);
    $mail->addAddress($to,'Kim Carlo'); //recipient
    $mail->Send();

    if($mail){
        $errors = "<font style='font-size:18px; color:#000000; line-height:150%'>Thank you!<br><br></font><font style='font-size:16px;''>We have received you message.<br>Your opinions and comments are very important to us and we read every message that we receive.<br>Our goal is to improve our service in any way we can, and we appreciate your taking the time to fill<br>
        out our feedback form.<br><br></font>";
    }else{
        $errors = "<font style='font-size:18px; color:#000000; line-height:150%'>There was a problem sending your message.<br><br>Please try again later.</font>";

    }
    header("refresh:10; url=/../contactform.php");
}else{
$errors = "<font style='font-size:18px; color:#000000; line- height:150%'>Please fill in email address and message fields<br><br></font>";
}

?>

here is my contact form

<form name="contact" method="POST" action="php/feedback.php">
            <label>Name:</label><br>
            <input type="text" name="name"/><br><br>

            <label>Email Address:<font color="red">*</font></label><br>
            <input type="email" name="email"/><br><br>

            <label>Subject:</label><br>
            <input type="text" name="subject"/><br><br>

            <label>Message:<font color="red">*</font></label><br>
            <textarea cols="45" rows="10" name="message"></textarea><br><br>
            <input type="submit" value="Send Message">

  • 写回答

1条回答 默认 最新

  • douyan2970 2015-03-08 06:02
    关注

    I solved it by removing this line..

    $mail->IsSMTP();
    

    thanks for the time guys...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我的数据无法存进链表里
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端