2014-02-28 4 views
0

SMTP 고급 인증을 사용하여 PHPMailer를 사용하여 테스트 메일을 보냅니다. 전자 메일 교환을 위해 SMTP 및 SSL과 함께 1and1.com 서버를 사용하고 있습니다. 타사 서버에서이 PHP 페이지를 실행해야합니다. 우리는 다운로드 한 PHPMailer 패키지에서 예제를 취했습니다. 우리는 "test_pop_before_smtp_advanced"예제와 "SMTP 고급 인증 테스트"예제를 시도했습니다. 두 경우 모두 동일한 오류가 발생합니다.SMTP 오류 : PHPMailer를 사용하여 SMTP 호스트에 연결할 수 없습니다.

SMTP Error: Could not connect to SMTP host.

다음은 메일 전송을 위해 작성한 php 파일입니다.

<html> 
<head> 
<title>PHPMailer - SMTP advanced test with authentication</title> 
</head> 
<body> 

<?php 
echo "hai"; 
include('class.phpmailer.php'); 
include('class.smtp.php'); 
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch 


$mail->SMTPSecure = "ssl"; 
$mail->SMTPKeepAlive = true; 
$mail->Mailer = "smtp"; 
echo "hai1"; 
$mail->IsSMTP(); // telling the class to use SMTP 

try { 

    $mail->Host  = "smtp.1and1.com"; // SMTP server 
    $mail->SMTPDebug = 1;      // enables SMTP debug information (for testing) 
    $mail->SMTPAuth = true;     // enable SMTP authentication 
    $mail->Host  = "smtp.1and1.com"; // sets the SMTP server 
    $mail->Port  = 587;     // set the SMTP port for the GMAIL server 
    $mail->Username = "[email protected]"; // SMTP account username 
    $mail->Password = "xxxxx";  // SMTP account password 
    $mail->AddReplyTo('[email protected]', 'First Last'); 
    $mail->AddAddress('[email protected]', 'John Doe'); 
    $mail->SetFrom('[email protected]', 'First Last'); 
    $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; 
    $mail->Body = 'hello'; 

if(!$mail->Send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} else { 
    echo "Message sent!"; 
} 
} catch (phpmailerException $e) { 
echo "error"; 
    echo $e->errorMessage(); //Pretty error messages from PHPMailer 
} catch (Exception $e) { 
echo "err"; 
    echo $e->getMessage(); //Boring error messages from anything else! 
} 
?> 

</body> 
</html> 

누구든지 이와 관련하여 도움이 될 수 있습니까? 동일한 목적으로 다른 쉬운 방법을 제안하십시오.

$mail->SMTPSecure = "ssl"; 
$mail->SMTPKeepAlive = true; 
$mail->Mailer = "smtp"; 

과 :이 줄을 제거하려고하면 SSL을 사용하지 않는 경우 SSL 포트를 465

을 기본으로하여 포트를 변경 시도 -

+1

, 당신은 [문제 해결 문서를 읽어야합니다 (불안) 연결을 자체 서명 된 인증서를 사용하여, 또는 비 SSL을 계속 허용 할 경우, PHPMailer에 대한 빠른 해결 방법은 사용하는 것입니다 ] (https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting). – Synchro

답변

0

SSL 연결을 사용하는 경우 감사합니다 ... 포트를 기본 포트 25로 변경하십시오.

연결할 수 없으므로 잠시 시간을내어 로그인 정보를 확인하십시오. 정확하지 않은 경우에도 실수로 입력 한 비밀번호를 잊어 버릴 수 있습니다.

2

나는 같은 문제가있어서 다른 포트, 도메인 및 보안 구성 시도를 거쳤습니다. 이 설정을 사용하려고하면 다른 도움말 사이트에서 해당 설정을 발견하고 저에게 도움이되었습니다.

$mail->IsSMTP();         // Set mailer to use SMTP 
$mail->Host = '74.208.5.2';    // Specify main and backup SMTP server (server name) 
$mail->Port = 25;    // TCP port to connect to 587 or 465, 425, 25 

$mail->Username = '[email protected]'; // SMTP username 
$mail->Password = 'xxxxxx';  // SMTP password 

$mail->SMTPAuth = true;  // Enable SMTP authentication 
$mail->SMTPSecure = 'tls';  // Enable TLS encryption, `ssl` also accepted 

나는 (당신이 핑 또는 후이즈으로 확인할 수 있습니다) TLS에 SMTPSecutre를 설정하거나 완전히이 줄을 제거, 호스트에 대해 smtp.1and1.net의 IP를 사용했고, 심지어 따라 1and1 불구하고 25로 포트를 설정 다른 항구를 더 자주 제안했다. 바라기를 이것은 누군가에게 약간의 시간을 절약합니다.

+0

다른 사이트에서이 설정을 발견 한 경우 해당 사이트에 연결하여 속성을 제공해야합니다. –

+0

포럼에 크게 호응을 얻지는 못했지만 몇 가지 잠재적 인 해결책이있는 것처럼 보였습니다. 그러나 여기 누군가가 그것을 확인하고 싶다면 여기에 있습니다. brian6은 내 답변이 주로 구성된 내용을 게시했습니다. 누구에게나 중요한 티켓이라면 1and1에서 알려주는 내용을 게시 할 수 있습니다. http://forums.sugarcrm.com/f3/fix-1and1-smtp-email-problem-73883/index2.html –

1

PHP는 SSL 연결에 대해 버전 5.6에서 갑자기 변경되었습니다. 이로 인해 많은 웹 문의 양식이 중단되고 종종 오류 메시지가 표시되지 않습니다.

이 같은 질문에 대한
$mail->SMTPOptions = array(
    'ssl' => array(
     'verify_peer' => false, 
     'verify_peer_name' => false, 
     'allow_self_signed' => true 
    ) 
); 
관련 문제