Jump to content

Problem with mail() function


Wolverine68

Recommended Posts

I created a form using the mail() function. Upon submission, it's just suppose to email the information entered.  Instead, I get the error "HTTP Error 405 - The HTTP verb used to access this page is not allowed."

 


<body>
<?php      
$recipient = "[email protected]"; 
$subject = "Registration Submission"; 
$body = "<h2>Registration Information:</h2>";	 
  
if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['question']))	  
{
$body .= "\r\nName: " . $_POST['name'];			
$body .= "\r\nEmail: " . $_POST['email']; 
$body .= "\r\nQuestion: " . $_POST['question'];   
}     
if (mail($recipient, $subject, $body))       
{        
print("Email successfully sent!");     
} 
else     
{         
print("The email could not be sent.");     
}   
?>
<form method="POST" action="">
<h2 align="center">Sending Email</h2>
<br />
<div>
<p>Enter your name and email address, a question, and click "Submit":</p>
<br />
<p>Name:<input type="text" name="name" size="20"></p>
<p>Email:<input type="text" name="email" size="20"></p> <p>Question:<input type="text" name="question" size="20"></p>
</div> 
<br /> 
<div>
<input type="submit" name="submit" value="Submit" />
</div> 
<br /> 
<div> 
<input type="reset" name="Reset" value="Start Over" />
</div>
</form>
</body>
</html>




 

Link to comment
https://forums.phpfreaks.com/topic/238412-problem-with-mail-function/
Share on other sites

405 is "Not Allowed" meaning the server is blocking it. I'm gonna go out on a limb and make an assumption that your using Godaddy as your hosting provider? Thats my first guess at least. Cause at the moment (though I could be overlooking something..) everything looks sound.

I know nothing about your hosting company. Nor do I know many free hosting companies (cept myself but thats usually friends/family). Also its worth mentioning that just cause PHP is supported doesnt mean it has all its functionality available often hosts will block some of the functionality of PHP like godaddy for example used to block the mail() function entirely and you had to do mail via form through 3rd party or there means of handling mail. Personally my host of choice and has been for a few years running is HostGator cheap, fairly friendly and all around not bad of a service for what they offer, and compared to its competion its a lot better then most of them. But they don't have free acccounts

I've used GoDaddy on and off for years, and I've never had a problem with mail().

 

If you Google this error, it seems to be a common occurrence with WinD'ohs Server running IIS 6. Something to do with file compression problems, from what I gather after a cursory look.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.