2017-09-19 6 views
1

PHP 메일러를 통해 이메일을 보내려고 할 때 오류가 발생합니다. 전자 메일을 보내는 코드는 다음과 같습니다.이 오류를 해결하는 방법 504 - 게이트웨이 시간 초과?

 require_once 'PHPMailer/PHPMailerAutoload.php'; 
     $response = array(); 
     //Create a new PHPMailer instance 
     $mail = new PHPMailer; 
     $mail->isSMTP(); 
     $mail->SMTPDebug = 0; 
     $mail->Debugoutput = 'html'; 
     $mail->Host = "mail.example.com"; 
     $mail->Port = 25; 
     $mail->SMTPAuth = true; 
     $mail->Username = "*****@Example.com"; 
     $mail->Password = "*******"; 
     $mail->setFrom($to, $name); 
     $mail->addAddress('*****', '***'); 
     $mail->Subject = $subject; 
     $message = '*******'; 
     $mail->msgHTML($message); 
     $mail->AltBody = 'This is a plain-text message body'; 
     $mail->SMTPOptions = array(
      'ssl' => array(
      'verify_peer' => false, 
      'verify_peer_name' => false, 
      'allow_self_signed' => true 
     ) 
    ); 
    if (!$mail->send()){ 
     // For Debugging 
     //return "Mailer Error: " . $mail->ErrorInfo; 
     $response['error'] = 'Something not right. Please check your details.'; 
    }else{ 
     $response['success'] = 'Your email has been sent successfully.'; 
    } 
    echo json_encode($response, JSON_PRETTY_PRINT); 

위 코드는 contact.php 파일 안에 있으며 form.php 파일에서 아약스를 통해 접근 중입니다. 그러나 많은 시간이 소요되고 결국에는 오류가 나타납니다.

Why am I seeing this page? 

The server that your request has reached is acting as a gateway or proxy to fulfil the request made by your client. 

Web Browser => Web Front-End => Web Back-End 

This server (Web Front-End) received an invalid response from an upstream (Web Back-End) server it accessed to fulfil the request. 

In most cases this will not mean that the upstream server is down, but rather that the upstream server and the gateway/proxy do not agree on the protocol for exchanging data. 

This problem is most commonly caused when there is a problem with IP communications between the Web Front and Back-Ends. Before you attempt to resolve this problem you should clear your browser cache completely. 

Our support staff will be happy to assist you in resolving this issue. Please contact our Live Support or reply to any Tickets you may have received from our technicians for further assistance. 

친절하게도 문제를 해결하는 방법을 알려 줄 수 있습니까?

+0

나는'SMTPDebug = 3'을 설정하고 브라우저가 아닌 명령 행에서 웹 서버가 오류를 보게됩니다. – Synchro

답변

1

나는 $ mail-> send()에 대한 호출이 설정이 잘못되었거나 방화벽이 설정되어있어 시간이 초과되었다고 추측합니다. 당신의 웹 서버 로그를 조사 할 것을 권합니다./var/log/nginx/error_log 또는 /var/log/php5/www.pool.log