2013-03-01 40 views
0
require_once "Mail.php"; 
error_reporting(E_ALL^E_STRICT); 
    $mail_To = $email; 
      $mail_Subject = "Reservation notification From Tamera Plaza Inn"; 
      $mail_Body = "First Name: $name\n". 
    "Last Name: $last\n". 
    "Email: $email \n". 
    "City: $city \n". 
    "Zip Code: $zip \n". 
    "Country: $country \n". 
    "Contact Number: $cnumber \n". 
    "Password: $password \n". 
    "Check In: $arrival\n ". 
    "Check Out: $departure\n ". 
    "Number of Adults: $adults\n ". 
    "Number of child: $child\n ". 
    "Total nights of stay: $result\n ". 
    "Room Type: $type\n ". 
    "Number of rooms: $nroom\n ". 
    "Payable amount: $payable\n ". 
    "Confirmation Number: $confirmation\n "; 

    $host = "localhost"; 
      $username = ""; 
      $password = ""; 

$smtp = Mail::factory('smtp', 
     array ('host' => $host, 
       'auth' => true, 
       'username' => $username, 
       'password' => $password)); 

    $mail = $smtp->send($mail_To, $mail_Subject, $mail_Body); 
     if (PEAR::isError($mail)) { 
      echo("<p>" . $mail->getMessage() . "</p>"); 
     } else { 
      echo("<p>Message successfully sent!</p>"); 
     } 

正如您所看到的,上面的代碼用於發送電子郵件。這就是我的網站試圖做的事情,但有一件事阻礙了我的成功,就是下面的錯誤。我似乎無法連接到我的郵件服務器,這是PEAR。我在這裏錯過了什麼嗎?郵寄SMTP錯誤PHP

ERROR: 
    Failed to connect to localhost:25 [SMTP: Failed to connect socket: No connection could be made because the target machine actively refused it. (code: -1, response:)] 

順便說一句,我使用Wampserver

+0

可能的重複http://stackoverflow.com/questions/4532486/failed-to-connect-to-mailserver-at-localhost-port-25。檢查你的'php.ini'文件中是否配置了'SMTP'。 – Rikesh 2013-03-01 13:42:44

+0

感謝您的回覆。我試過看過,但我不明白。 – 2013-03-01 13:54:29

+0

我應該在sendmail_from中放入什麼? – 2013-03-01 13:57:29

回答

0
No connection could be made because the target machine actively refused it. 

這是你的問題,因爲在錯誤消息中指出。檢查郵件服務器的防火牆設置。

+0

請注意,如果我詢問如何檢查我的郵件服務器的防火牆設置? – 2013-03-01 13:55:32