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 = "me@yahoo.com"; 
$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
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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.