2011-09-16 4 views
0

PHP 메일 스크립트를 실행할 때 이상한 오류가 발생했습니다. 해당 서버와 관련하여 보낸 사람을 확인할 수 없습니다. 다음 오류가 표시됩니다.PHP에서 이메일을 보내는 중 문제가 발생했습니다

Failed to add recipient [email protected] [SMTP: Invalid response code received from server (code:550, response: Verification failed for unrouteable address Sendor verify failed)]

이 오류가 발생할 수있는 이유를 알고 계십니까?

<?php 
require_once "Mail.php"; 
$kw = (string)$_GET['keyword']; 
$e = (string)$_GET['emailid']; 
$uname="xxx"; 
$password="xxx"; 
$con=mysql_connect("Localhost","root",""); 
if(!$con) 
{ 
die('Could not connect: ' . mysql_error()); 
} 

mysql_select_db("mysql_db",$con); 

mysql_query("INSERT INTO mail_alert  (uname,emailid,password,keyword)values('$kw','$e','$uname','$password')"); 



$from = "mail.domain.com"; 
$to = $e; 
$subject = "Hi!"; 
$body = "Hi,\n\nHow are you?"; 
$host = "ssl://domain.com"; 
$port="465"; 
$username = "login"; 
$password = "xxx"; 

$headers = array ('From' => $from, 
'To' => $to, 
'Subject' => $subject); 
$smtp =Mail::factory('smtp', 
array ('host' => $host, 
'port' => $port, 
'auth' => true, 
'username' => $username, 
'password' => $password)); 

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

if (PEAR::isError($mail)) { 
echo("<p>" . $mail->getMessage() . "</p>"); 
} else { 
echo("<p>Message successfully sent!</p>"); 
} 


mysql_close($con); 

?> 당신이 여기서 뭘하는 것은 당신이 domain.com의 소유자/사용자 인으로 이메일을 보내려고

답변

2

.

PHP를 통해 이메일을 보내려면 일부 이메일 서버의 유효한 자격증 명을 제공해야합니다. 컴퓨터에서 직접 메일 서버를 만들 수 있지만 약간의 노력이 필요합니다. 음, 유닉스에서는 더 쉽습니다. Windows에서 hMailServer과 같은 소프트웨어를 다운로드해야합니다.

쉬운 해결책은 create account on some third-party service, e.g. Gmail 일 수 있습니다.

Gmail.com 계정을 만들고 here 스크립트에 설정할 구성 데이터가 있어야합니다 (SMTP 주소, 포트 번호, 사용자 이름과 비밀번호는 Gmail 계정입니다).

SMTP: smtp.gmail.com 
Port for TLS/STARTTLS: 587 
Port for SSL: 465 
User name: your Gmail email address 
Password: your Gmail password 

This example이 도움이 될 수 있습니다.

관련 문제