여기 거의 일주일 동안 붙어 있습니다. 실제로 튜토리얼의 단계를 따라 갔지만 운이 없었습니다. 이 phpmailer을 다운로드하고 버전 5.4.2를 얻었습니다. 아래의 코드는이 다운로드 된 phpmailer의 예이지만 나에게는 적합하지 않습니다. 이미 sendmail 및 php.ini를 구성했습니다. 나는 또한 와 같은 몇몇 연장을 가능하게했다 openssl 그리고 phpsocket php smtp 및 아파치 단위. 누군가가이 문제로 나를 도울 수 있기를 바랍니다. 다음은 내 코드입니다.SMTP -> ERROR : 서버에 연결하지 못했습니다. 다음 보낸 사람 주소가 실패했습니다. : 연결되지 않은 상태에서 Mail()을 호출했습니다. 메일러 오류
<html>
<head>
<title>PHPMailer - SMTP (Gmail) basic test</title>
</head>
<body>
<?php
error_reporting(E_STRICT);
date_default_timezone_set('America/Toronto');
require_once('../class.phpmailer.php');
class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = "dasdf";
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "ggg"; // GMAIL password
$mail->SetFrom('[email protected]', 'jj');
$mail->AddReplyTo("[email protected]","jj");
$mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "[email protected]";
$mail->AddAddress($address, "Dave");
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
을 추가하여 SMTP 디버깅을 사용한다'$ 메일 -> Host' 두 번 정의했다. 그게 아무것도 영향을 미치지 않거나 첫 번째 항목을 덮어 쓰는 것인지 확실하지 않습니다. 또한 첨부 파일을 제거하고 전송하는지 확인합니다. 그 외에는 어떤 문제도 보이지 않습니다. – Devon
켈빈이 말하는 것을하십시오. [this example] (https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps)을 시작점으로 사용해야합니다. 또한 Gmail의 최근에 변경된 인증 정책에 대한 참고 사항을 참조하십시오 (https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting). – Synchro