2012-03-02 34 views
2
<?php 
require("./PHPMailer/class.phpmailer.php"); 

    global $error; 

    $from = $_REQUEST['from']; 
    $from_name = $_REQUEST['from_name']; 
    $subject = $_REQUEST['subject']; 
    $body = $_REQUEST['body']; 
    $is_gmail = $_REQUEST['is_gmail'] =true; 
    $to = $_REQUEST['to']; 
    $to = "[email protected]"; // used for testing only 
    $mail = new PHPMailer(); 
    $mail->IsSMTP(); 
    $mail->SMTPAuth = true; 
    if ($is_gmail) { 
     $mail->SMTPSecure = 'tls'; 
     $mail->Host = 'smtp.ks101.fdsfd.eu'; 
     $mail->Username = '[email protected]'; 
     $mail->Password = "pass"; 
     $mail->SMTPDebug = 1; 
    } else { 
     $mail->Host = SMTPSERVER; 
     $mail->Username = SMTPUSER; 
     $mail->Password = SMTPPWD; 
    }   
    $mail->SetFrom($from, $from_name); 
    $mail->Subject = $subject; 
    $mail->Body = $body; 
    $mail->AddAddress($to); 
    if(!$mail->Send()) { 
     $error = 'Mail error: '.$mail->ErrorInfo; 
     echo(false); 
     return false; 
    } else { 
     $error = 'Message sent!'; 
     echo(true); 
     return true; 
    } 
?> 

我顯示以下代碼託管提供商,他們告訴我它應該工作。我嘗試上傳,但沒有奏效。有人可以幫我發送郵件在PHP

當我嘗試網站應該是(實際上可能是PHP服務器)的實際服務器時,我得到了錯誤。

<br /> 
<b>Warning</b>: stream_socket_enable_crypto() [<a href='streams.crypto'>streams.crypto</a>]: this stream does not support SSL/crypto in <b>/home/www/web420/html/test/PHPMailer/class.smtp.php</b> on line <b>197</b><br /> 
SMTP -> ERROR: RSET failed: 
<br />Language string failed to load: tls 

當我嘗試我的服務器我得到了相同的代碼錯誤上(IIS 7)

<br /> 
<b>Warning</b>: stream_socket_enable_crypto() [<a href='streams.crypto'>streams.crypto</a>]: this stream does not support SSL/crypto in <b>C:\inetpub\vhosts\test.com\subdomains\test\httpdocs\appbounce\PHPMailer\class.smtp.php</b> on line <b>197</b><br /> 

我不知道什麼是該網站所使用的服務器。我得到了不同的-2錯誤。請有人驗證,如果他們是我的代碼中的問題。我究竟需要做什麼。

感謝

+0

郵件();工作嗎? http://www.php.net/manual/en/function.mail.php – Michas 2012-03-02 13:54:41

+0

嘿@Michas你能告訴我如何設置密碼嗎? – user1240424 2012-03-02 14:04:28

+0

如果你很幸運並且在PHP服務器上配置了郵件,它將無需密碼。 – Michas 2012-03-02 14:17:10

回答

0

一些快速提示

添加此

$mail->Port = 465; 

改變這種

$mail->SMTPSecure = "ssl"; 

如果兩個不行....然後在路由器級身份驗證問題託管部分

+0

你是對的。它適用於Gmail,但不適用於我的域帳戶。 – user1240424 2012-03-02 14:02:52

+0

聯繫您的託管服務提供商...這絕對不是一個腳本的問題.... – 2012-03-02 14:06:40

+0

先生,我已經聯繫他們,花了我2​​天的時間,但他們仍然沒有幫助我的代碼。他們仍然有許多想法,但沒有解決他們客戶的問題。 – user1240424 2012-03-02 15:03:32