简体   繁体   English

加载资源失败:服务器响应状态为405(不允许使用方法)

[英]Failed to load resource: the server responded with a status of 405 (Method Not Allowed)

This is the error coming while i try to send mail using php. 这是我尝试使用php发送邮件时出现的错误。
Failed to load resource: the server responded with a status of 405 (Method Not Allowed) sendmail.php 无法加载资源:服务器的响应状态为405(不允许使用方法)sendmail.php

this is the form 这是表格

<form action="sendmail.php" method="post" id="contactform" >
    <div id='name-error' class='error'>Please enter your name.</div>
    <input name="name" placeholder="Name" class="form-control" type="text" id="name">
    <div id='email-error' class='error'>Please enter your valid E-mail ID.</div>
    <input name="email" placeholder="Email" class="form-control"  type="text" id="email">
    <div id='subject-error' class='error'>Please enter the subject.</div>
    <input name="subject" placeholder="Subject" class="form-control" type="text" id="subject">
    <div id='message-error' class='error'>Please enter your message.</div>
    <textarea name="message" placeholder="Message" id="message" rows="4" class="form-control"></textarea>
    <div id='mail-success' class='success'>Your message has been sent successfully.</div>
    <div id='mail-fail' class='error'> Sorry, error occured this time sending your message.</div>
    <input type="submit" value="Send Message" class="form-control" id="send-message">

</form>

this is the query 这是查询

$.post("sendmail.php", $("#contactform").serialize(), function(result){
enter code here if (result == 'sent'){
$('#mail-success').slideDown(500).delay(1000).slideUp(500);
        $('#send-message').removeAttr('disabled').attr('value', 'Send Message');
} else{
$('#mail-fail').slideDown(500).delay(1000).slideUp(500);
        $('#send-message').removeAttr('disabled').attr('value', 'Send Message');
}
});
}
});

this is the sendmail.php file 这是sendmail.php文件

<?php

$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$from = "info@vonesoft.com";
$to = "mujtaba1004@gmail.com";
$head = "New Contact Lead - VOneSoft";
$body = "Hi , <br /><br />";

$body .= "<table border='1' cellpadding='4' cellspacing='0'>";
$body .= "<tr><td>Name </td><td> " . $name . " </td></tr>";
$body .= "<tr><td>Email </td><td> " . $email . " </td></tr>";
$body .= "<tr><td>Subject </td><td> " . $subject . " </td></tr>";
  $body .= "<tr><td>Message </td><td> " . $message . " </td></tr>";
$body .= "</table>";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= "From:" . $from "\r\n";

mail($to, $head, $body, $headers);
echo '1';
?>

You forgot to concatenate here 你忘了在这里串联

  $headers .= "From:" . $from. "\r\n";
                -------------^

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 加载资源失败:服务器响应状态为405(不允许使用方法) - Failed to load resource: the server responded with a status of 405 (Method Not Allowed) 加载资源失败:服务器响应,状态为404 Not Found - Failed to load resource: the server responded with a status of 404 Not Found 无法上传文件加载资源失败:服务器响应状态为503 - Cant upload file Failed to load resource: the server responded with a status of 503 Laravel 7 - 加载资源失败:服务器响应状态为 400(错误请求) - Laravel 7 - Failed to load resource: the server responded with a status of 400 (Bad Request) Laravel Chained Select加载资源失败:服务器响应状态为500 - Laravel Chained Select Failed to load resource: the server responded with a status of 500 加载资源失败:服务器响应状态为500(); 在当地环境中工作 - Failed to load resource: the server responded with a status of 500 (); works in local environment 加载资源失败:服务器在 Heroku 上响应状态为 404(未找到)Laravel - Failed to load resource: the server responded with a status of 404 (Not Found) Laravel on Heroku 无法加载资源:服务器响应状态为500,Codeigniter项目 - Failed to load resource: the server responded with a status of 500, Codeigniter project 加载资源失败:服务器响应状态为403(禁止) - Failed to load resource: the server responded with a status of 403 (Forbidden) Wordpress 无法加载样式:加载资源失败:服务器响应状态为 404(未找到) - Wordpress can't load styles: Failed to load resource: the server responded with a status of 404 (Not Found)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM