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 (标签-STM32|关键词-智能小车)
  • ¥20 关于#stm32#的问题,请各位专家解答!
  • ¥15 (标签-python)
  • ¥15 第一个已完成,求第二个做法
  • ¥20 搭建awx,试了很多版本都有错
  • ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?
  • ¥15 activiti工作流问题,求解答
  • ¥15 有人写过RPA后台管理系统么?
  • ¥15 Bioage计算生物学年龄
  • ¥20 如何将FPGA Alveo U50恢复原来出厂设置哇?