phpMailer不发送电子邮件

时间:2015-07-14 13:41:24

标签: php phpmailer

我的phpMailer有问题。当我发送表单时,它会返回此错误:

SMTP ERROR: Failed to connect to server: Connection timed out (110) SMTP connect() failed.

这是我的PHP代码

$Mail = new PHPMailer();

    $body =     "Nome: <strong>".$nome."</strong><br>
                Email: <strong>".$email."</strong><br>
                Txt: <strong>".$txt."</strong><br>";

    echo "$body";

    $Mail->IsSMTP(); // Use SMTP
    $Mail->Host        = "smtp.gmail.com"; // Sets SMTP server
    $Mail->SMTPDebug   = 1; // 2 to enable SMTP debug information
    $Mail->SMTPAuth    = TRUE; // enable SMTP authentication
    $Mail->SMTPSecure  = "ssl"; //Secure conection
    $Mail->Port        = 465; // set the SMTP port
    $Mail->Username    = 'email@gmail.com'; // SMTP account username
    $Mail->Password    = 'password'; // SMTP account password
    $Mail->Priority    = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
    $Mail->CharSet     = 'UTF-8';
    $Mail->Encoding    = '8bit';
    $Mail->Subject     = 'Test Email Using Gmail';
    $Mail->ContentType = 'text/html; charset=utf-8\r\n';
    $Mail->From        = 'email@gmail.com';
    $Mail->FromName    = 'GMail Test';
    $Mail->WordWrap    = 900; // RFC 2822 Compliant for Max 998 characters per line

    $Mail->AddAddress( 'email@gmail.com' ); // To:
    $Mail->isHTML( TRUE );
    $Mail->Body    = $txt;
    $Mail->AltBody = "Nome: <strong>".$nome."</strong><br>
                      Email: <strong>".$email."</strong><br>
                      Txt: <strong>".$txt."</strong><br>";;
    $Mail->Send();
    $Mail->SmtpClose();

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

我尝试从Register.it托管Linux,这是URL dmatermoidraulica.simply-webspace.it

0 个答案:

没有答案