2

这是我的代码,但它仍然没有发送邮件。可能是什么问题呢?

require 'class.phpmailer.php';// path to the PHPMailer class
require 'class.smtp.php';

            $mail = new PHPMailer();  

            $mail->IsSMTP();  // telling the class to use SMTP
            $mail->Mailer = "smtp";
            $mail->Host="smtp.gmail.com";
            $mail->SMTPSecure='tls';
            $mail->Port =465;             
            $mail->SMTPAuth = true; // turn on SMTP authentication
            $mail->Username = "mymailgmail.com"; // SMTP username
            $mail->Password = "mypassword"; // SMTP password 
            $mail->SMTPDebug = 1;

            $mail->AddAddress("mymail@gmail.com","Title");
            $mail->SetFrom($visitor_email, $name);
            $mail->AddReplyTo($visitor_email,$name);

            $mail->Subject  = "Message from  Contact form";
            $mail->Body     = $user_message;
            $mail->WordWrap = 50;  

            if(!$mail->Send()) {
            echo 'Message was not sent.';
            echo 'Mailer error: ' . $mail->ErrorInfo;
            } else {
            echo 'Message has been sent.';
            }

// header('位置:thank-you.html'); }

4

1 回答 1

1

我曾经有过类似的问题。事实证明,尝试使用 ipv6 地址进行连接。从网络接口中删除 IPv6 地址后它工作正常。

于 2013-10-01T12:36:49.507 回答