2010-02-04 3 views
0

PHP로 이메일 문의 양식을 작성했습니다. 배 메일 패키지를 사용하여 이메일을 보내고 있습니다. 그것은 내 개발 컴퓨터에서 멋지게 작동하지만 서버에서는 작동하지 않습니다. 다음은 코드입니다.PHP로 배로 메일을 보낼 때 문제가 발생했습니다.

////////////////////////////////////////////////// 
// EMAIL OPTIONS 
////////////////////////////////////////////////// 
$to = "[email protected]";    
$subject = "Contact Form Submission";   
$smtphost = "localhost"; 
$port = "25"; 
$authenticate = false; 
$username = "smtp_username"; 
$password = "smtp_password"; 

// create and send the email 
$from = $_POST['fullname'] . " <" . $_POST['email'] . ">"; 
$body = str_replace($ph, $rv, $emailTemplate); 

$headers = array (
    'MIME-Version' => '1.0', 
    'Content-type' => 'text/html; charset=iso-8859-1', 
    'From' => $from, 
    'To' => $to, 
    'Subject' => $subject); 

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

$mail = $smtp->send($to, $headers, $body); 

$error = PEAR::isError($mail); 

if ($error){ 
    echo 'An error occurred.'; 
} 
else { 
    require('thanks.php'); 
    exit; 
} 

왜 서버에서 오류가 발생하는지 알 수 없습니다. $ error 객체에서 좀 더 유용한 정보를 얻으려면 어떻게해야합니까? 와

반향 $ 오류가 발생합니다

1 

답변

2

http://pear.php.net/manual/en/core.pear.pear-error.php 봐가있는 $smtphost = "localhost"; 서버 도메인에 URL을 바꾸는 시도하고 같은 수행하지 않습니다

 
if ($error){ 
    echo 'An error occurred.'; 
    echo $error->getMessage(), "\n"; 
} 
else { 
    require('thanks.php'); 
    exit; 
} 
0

+0

을 $ error 객체에서 더 유용한 정보를 얻는 것에 대한 제 질문에 대답하십시오. 나는 내 SMTP 서버 호스트가 잘못되었다고 걱정하지 않는다. –

+0

$ 오류 – streetparade

+0

의 출력을 게시하십시오. $ 오류를 표시하는 경우 1을 얻습니다. –

관련 문제