Phpmailer类不适用于域名

时间:2013-09-10 09:47:03

标签: php phpmailer

我有phpmailer这个脚本,它可以在 localhost 中使用相同的数据,但在我的域下的服务器中没有。这是我的剧本:

<?php

  include("class.phpmailer.php");   

    $Mail = new PHPMailer();
    $Mail->IsSMTP();
    $Mail->Host = 'smtp.gmail.com';
    $Mail->SMTPDebug = 1; 
    $Mail->SMTPAuth = true;
    $Mail->SMTPSecure = 'tls';
    $Mail->Port = 587;
    $Mail->Username = 'myemail@gmail.com';
    $Mail->Password = 'mypassword';
    $Mail->Priority = 1;
    $Mail->CharSet = 'UTF-8';
    $Mail->Encoding = '8bit';
    $Mail->Subject = 'Test Message';
    $Mail->ContentType = 'text/html; charset=utf-8\r\n';
    $Mail->From = 'myemail@gmail.com';
    $Mail->FromName = 'myemail@gmail.com';
    $Mail->WordWrap = 900;

    $Mail->AddAddress('emailreceiver@domain.com');
    $Mail->isHTML(TRUE);
    $Mail->Body = 'Hello how are you ?';
    $Mail->Send();
    $Mail->SmtpClose();

    if ($Mail->IsError()) {
        echo "ERROR<br /><br />";
    } else {
        echo "OK<br /><br />";
    }
?>

正如我所提到的,这个脚本在我的计算机中从localhost可以正常工作,但如果它在我的域下则不行。为什么会这样?

0 个答案:

没有答案