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...

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

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作