可以解决我的“SMTP错误:无法验证”错误

时间:2016-07-25 15:43:32

标签: php email smtp phpmailer smtp-auth

我的PHPmailer功能有问题。

我希望我的注册表格能够向每位新注册会员发送邮件。

我收到此错误代码。 SMTP错误:无法进行身份验证。

我已经联系了我的虚拟主机,他们说我有正确的用户名,密码,smtp服务器等。

        include "class.smtp.php";
        include "class.phpmailer.php";

        $Host = "mail.smtp.com";            // SMTP servers
        $Username = "support@mymail.com";   // SMTP password
        $Password = "mymailpassword";

        $From = "support@mymail.com";
        $FromName = "My name";

        $ToEmail = $mail;
        $ToName = $username;
        $header = str_replace('%homepage_url%', $hp_url, $_language->module['mail_subject']);
        $Message = str_replace(Array('%nickname%', '%username%', '%password%', '%activationlink%', '%pagetitle%', '%homepage_url%'), Array(stripslashes($nickname), stripslashes($username), stripslashes($pwd1), stripslashes($validatelink), $hp_title, $hp_url), $_language->module['mail_text']);

        $mail = new PHPMailer();

        $mail->IsSMTP();                    // send via SMTP
        $mail->Host     = $Host; 
        $mail->SMTPAuth = true;             // turn on SMTP authentication
        $mail->Username = $Username;  
        $mail->Password = $Password; 

        $mail->From     = $From;
        $mail->FromName = $FromName;

        $mail->AddAddress($ToEmail , $ToName);

        $mail->WordWrap = 50;               // set word wrap
        $mail->Priority = 1; 
        $mail->IsHTML(true);  
        $mail->Subject  =  $header;

        $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
        $mail->MsgHTML($Message);

        $mail->CharSet="UTF-8";

        if(!$mail->Send()){
            redirect("index.php",$_language->module['register_successful'],10);
            $show = false;
        } else {
            redirect("index.php",$_language->module['register_successful'],10);
            $show = false;
        }

0 个答案:

没有答案