제 코드를 변경했지만 효과가 없습니다. 코드 자체는 오류를 반환하지 않고 대신 성공 메시지를 제공합니다. 내 릴레이로 Gmail을 사용하고 있습니다.phpmailer 6.0 성공 메시지하지만 메일을 릴레이로 사용하여 메일을 수신하지 못했습니다.
P.S, 수정본으로 사용한 것과 비슷한 질문을했기 때문에 $mail->IsSMTP();
을 주석 처리했습니다. "연결에 실패했습니다"라는 오류가 발생했습니다.
저는 PHPmailer 6.0을 사용하고 있습니다.
2017-12-27 07:58:54 Connection: opening to smtp.gmail.com:465, timeout=300, options=array() 2017-12-27 07:58:54 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.gmail.com:465 (Network is unreachable) [/srv/disk2/2564570/www/consorttest.dx.am/vendor/phpmailer/phpmailer/src/SMTP.php line 325] 2017-12-27 07:58:54 SMTP ERROR: Failed to connect to server: Network is unreachable (101) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
치명적인 오류 : catch되지 않은 PHPMailer \ PHPMailer \ 예외 : 나는 $mail->IsSMTP();
내가이 오류 로그를 얻을 주석을 제거하면
<?php
require_once('vendor/autoload.php');
define('GUSER', '[email protected]'); // GMail username
define('GPWD', '*********'); // GMail password
function smtpmailer($to, $from, $from_name, $subject, $body) {
\t global $error;
\t $mail = new PHPMailer\PHPMailer\PHPMailer(true); // create a new object
\t //$mail->IsSMTP(); // enable SMTP
\t $mail->SMTPDebug = 4; // debugging: 1 = errors and messages, 2 = messages only
\t $mail->SMTPAuth = true; // authentication enabled
\t $mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail
\t $mail->Host = 'smtp.gmail.com';
\t $mail->Port = 465;
\t $mail->Username = GUSER;
\t $mail->Password = GPWD;
\t $mail->SetFrom($from, $from_name);
\t $mail->Subject = $subject;
\t $mail->Body = $body;
\t $mail->AddAddress($to);
\t if(!$mail->Send()) {
\t \t $error = 'Mail error: '.$mail->ErrorInfo;
\t \t return false;
\t } else {
\t \t $error = 'Message sent!';
\t \t return true;
\t }
}
smtpmailer('[email protected]', '[email protected]', 'yourName', 'test mail message', 'Hello World!');
if (smtpmailer('[email protected]', '[email protected]', 'yourName', 'test mail message', 'Hello World!')) {
\t // do something
}
if (!empty($error)) echo $error;
?>
: 여기
내 코드는 SMTP 연결 실패. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting /srv/disk2/2564570/www/consorttest.dx.am/vendor/phpmailer/phpmailer/src/PHPMailer.php:1726 스택 추적 : # 0 /srv/disk2/2564570/www/consorttest.dx.am/ PHPMailer \ PHPMailer \ PHPMailer-> smtpSend ('Date : Wed, 27 D ...', 'Hello World! \ r \ n') # 1/srv /disk2/2564570/www/consorttest.dx.am/vendor/phpmailer/phpmailer/src/PHPMailer.php(1320) : PHPMailer \ PHPMailer \ PHPMailer-> postSend() # 2/srv/disk2/2564570/www/consorttest .dx.am/mailtest.php (23) : PHPMailer \ PHPMailer \ PHPMailer-> send() # 3 /srv/disk2/2564570/www/consorttest.dx.am/mailtest.php(32) : smtpmailer ('to @mail.com ',' [email protected] ','yourName ','test mail messa ... ','Hello World! ') # 4 {main}/srv/disk2/2564570/www/consorttest .dx.am/vendor/phpmailer/phpmailer/src/PHPMailer.php on line 1726