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
을 기본으로하여 포트를 변경 시도 -
, 당신은 [문제 해결 문서를 읽어야합니다 (불안) 연결을 자체 서명 된 인증서를 사용하여, 또는 비 SSL을 계속 허용 할 경우, PHPMailer에 대한 빠른 해결 방법은 사용하는 것입니다 ] (https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting). – Synchro