405不允许使用nginx phpmailer

时间:2016-07-14 18:38:16

标签: php nginx phpmailer http-status-code-405

我刚刚上传了一个页面,发现虽然phpmailer是在localhost中发送的,但它并没有发送电子邮件。得到405不允许nginx。有帮助吗?以下是代码......

if (isset($_POST['msg_submit'])) {                                                  

    $mail = new PHPMailer;

    $mail->isSMTP();                            
    $mail->SMTPAuth = true;                     
    $mail->Host = $smtp_server_w;                   
    $mail->Username = $username_w; 
    $mail->Password = $password_w;
    $mail->SMTPSecure = "tls";                
    $mail->Port = 587;

    $mail->setFrom("test@gmail.com", "test");

    $sql_mail = "SELECT * FROM order_details ORDER BY id DESC LIMIT 1";

    $run_mail = mysqli_query($conn, $sql_mail);
    while ($row_mail = mysqli_fetch_assoc($run_mail)) {
        $mail->addAddress($row_mail['user_email'], $row_mail['user_name']);   

        $mail->isHTML(true); 

        $bodyContent = message;
        $mail->Subject = test message ;
        $mail->Body    = $bodyContent;
        $mail->AltBody = $bodyContent;

        if(!$mail->send()) {
            echo "Message could not be sent.";
            $error = '<div class="alert alert-danger"><strong>Mailer Error: '. $mail->ErrorInfo.'</strong></div>';
        } else {
            $error = '<div class="alert alert-default"><strong>Message has been sent</strong></div>';
        }
    }
}

0 个答案:

没有答案
相关问题