2014-01-29 3 views
2

나는 dan.creativeloafing.com에서 PHP 응용 프로그램을 만들었습니다. 이것은 단지 양식 데이터를 취하여 html 페이지를 만든 다음 해당 페이지의 내용을 [email protected]으로 전자 메일로 보냅니다. 며칠 전 일하다 멈췄다. 그 이후로 나는 이것을 알아 내려고 노력해 왔습니다. mail() PHP 함수를 사용하여 PHPMailer 라이브러리로 전환했습니다. 이것은 아마도 이메일을 보내고 있으며 확인을 얻지 만 아무도 이메일을받지 못하므로 바운스 백이나 오류가 발생하지 않습니다. 이 코드의 JIST입니다 '. 제안이 전송되었습니다'스크립트는 항상 도달 PHPMailer가 보내지는 않지만 오류가 없습니다.

//PHPMailer 
$mail = new PHPMailer; 

$mail->isSMTP();         // Set mailer to use SMTP 
$mail->Host = 'relay-hosting.secureserver.net';  // Specify main and backup server 
$mail->Port = 25; 
$mail->SMTPAuth = false;       // Enable SMTP authentication 
$mail->SMTPSecure = 'tsl';       // Enable encryption, 'ssl' also accepted 
$mail->Username = '[email protected]';    // SMTP username 
$mail->Password = '*******';       // SMTP password 

$mail->SMTPDebug = 0; 

$mail->WordWrap = 50; 
$mail->From = '[email protected]y.com'; 
$mail->FromName = 'DAN Application'; 
$mail->addAddress('[email protected]');    // Name is optional 
$mail->addReplyTo($repEmail); 
$mail->addCC('[email protected]'); 

$mail->isHTML(true); 

$mail->Subject = "New DAN Request: ".$campaignName; 
$mail->msgHTML(file_get_contents('./tmp/DAN_REQUEST_'.$specialString.$randomNumber.'.html')); 

if(!$mail->send()) { 
     echo '<br />Proposal could not be sent.<br />'; 
     echo 'Mailer Error: ' . $mail->ErrorInfo; 
     exit; 
} else { 
    echo 'Proposal has been sent'; 
} 

가 너무. 이것은 나를 미치게하고있다!

+0

여기에 메일 암호를 게시 그것이 자리 않는 한 나쁜 생각이다. –

답변

0

try ... catch 및 PHPMailer (true)를 사용하십시오. https://github.com/Synchro/PHPMailer/blob/master/examples/exceptions.phps

//Create a new PHPMailer instance 
//Passing true to the constructor enables the use of exceptions for error handling 
$mail = new PHPMailer(true); 

try { 

mail->isSMTP();         // Set mailer to use SMTP 
$mail->Host = 'relay-hosting.secureserver.net';  // Specify main and backup server 
$mail->Port = 25; 
$mail->SMTPAuth = false;       // Enable SMTP authentication 
$mail->SMTPSecure = 'tsl';       // Enable encryption, 'ssl' also accepted 
$mail->Username = '[email protected]';    // SMTP username 
$mail->Password = '*******';       // SMTP password 

$mail->SMTPDebug = 0; 

$mail->WordWrap = 50; 
$mail->From = '[email protected]'; 
$mail->FromName = 'DAN Application'; 
$mail->addAddress('[email protected]');    // Name is optional 
$mail->addReplyTo($repEmail); 
$mail->addCC('[email protected]'); 

$mail->isHTML(true); 

$mail->Subject = "New DAN Request: ".$campaignName; 
$mail->msgHTML(file_get_contents('./tmp/DAN_REQUEST_'.$specialString.$randomNumber.'.html')); 

$mail->send(); 
echo 'Proposal has been sent'; 

} catch (phpmailerException $e) { 
echo $e->errorMessage(); //Pretty error messages from PHPMailer 

} catch (Exception $e) { 
echo $e->getMessage(); //Boring error messages from anything else! 
} 
+0

나는 이것을 시험해 보았고 여전히 '제안서가 보내졌다'고 울부 짖었다. 이것은 문제가 내 목표가 아니라 호스트 (godaddy)를 의미합니까? – user3250627

+0

가능합니다. 다른 SMTP 서버로 변경하십시오. –

-1

생각 센드() 전송해야한다()

if(!$mail->Send()) { 
+0

해결 방법과 해결 방법을 설명해주십시오. 이것은이 질문에 대한 미래의 방문자가 귀하의 솔루션을 이해하는 데 도움이됩니다. – War10ck

+0

올바른 사용법은 실제로 $ mail-> send() – user3250627

1

그래서 여기 일이 GoDaddy와 그들에 내 도메인 이름을 포함 이메일을 차단 한 것입니다 있었는지. 이것이 스팸 문제인지 확실하지 않지만 현재 조사 중입니다. 간단한 메일() 함수를 사용하여 이메일을 보내고 omgsurvey.com에 대한 참조를 이메일에서 제거했습니다. 바보,이 메일은 오직 두 이메일 주소로 발송되었습니다!

1

아닌가요 : 있어야

$mail->SMTPSecure = 'tsl'; 

:

$mail->SMTPSecure = 'tls'; 
관련 문제