fatmikey Posted February 11, 2009 Share Posted February 11, 2009 I switched web hosting companies and my mail statement worked fine with the old company but with the new company I keep getting this error: Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in /home/content/h/e/w/hewittm/html/registration.php on line 171 Here is my code, any suggestions would be greatly appreciated: if (mail($To, $Subject, $Body, $Headers)) { print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.htm\">"; } else { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } Quote Link to comment https://forums.phpfreaks.com/topic/144779-solved-error-bad-parameters-with-php-mail-funtion-please-help/ Share on other sites More sharing options...
rhodesa Posted February 11, 2009 Share Posted February 11, 2009 what are the values of $To, $Subject, $Body, $Headers ? Quote Link to comment https://forums.phpfreaks.com/topic/144779-solved-error-bad-parameters-with-php-mail-funtion-please-help/#findComment-759710 Share on other sites More sharing options...
fatmikey Posted February 11, 2009 Author Share Posted February 11, 2009 Nothing Special...... $To = "user@domain.com"; $Subject = "Test"; $Body = "nothing special"; $Headers = "From: " . $FirstName . " " . $LastName . " <" . $Email . ">\r\n"; $Headers .= "Bcc: user2@domain.com"; Quote Link to comment https://forums.phpfreaks.com/topic/144779-solved-error-bad-parameters-with-php-mail-funtion-please-help/#findComment-759866 Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 Does the new host require certain headers? I would contact your host and see what is required to get it to work. Quote Link to comment https://forums.phpfreaks.com/topic/144779-solved-error-bad-parameters-with-php-mail-funtion-please-help/#findComment-759873 Share on other sites More sharing options...
killah Posted February 11, 2009 Share Posted February 11, 2009 Here are some option's. 1.- Check your PHP version. 2.- Mail your hosting company and report it to them. 3.- Try removing the Bcc: Header's and see if that work's. Quote Link to comment https://forums.phpfreaks.com/topic/144779-solved-error-bad-parameters-with-php-mail-funtion-please-help/#findComment-759874 Share on other sites More sharing options...
rhodesa Posted February 11, 2009 Share Posted February 11, 2009 Try removing the headers all together and add them in line by line to find your problem. My guess is your hosting company doesn't allow a From header that is outside of your domain. This is becoming more and more common among hosting services as a security measure Quote Link to comment https://forums.phpfreaks.com/topic/144779-solved-error-bad-parameters-with-php-mail-funtion-please-help/#findComment-759915 Share on other sites More sharing options...
PFMaBiSmAd Posted February 11, 2009 Share Posted February 11, 2009 Along those same lines, the From: address should always be a mail box hosted at the sending mail server and you should use the Reply-to: address for any user entered email address. Give this a try for your header separators (which are \r\n now) - Note: If messages are not received, try using a LF (\n) only. Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822. Quote Link to comment https://forums.phpfreaks.com/topic/144779-solved-error-bad-parameters-with-php-mail-funtion-please-help/#findComment-759936 Share on other sites More sharing options...
fatmikey Posted February 12, 2009 Author Share Posted February 12, 2009 Got it! Thanks guys Here's what the problem was, you were right PFMaBiSmAd, I removed all \r\n from the headers info and it works now. You guys rock! Have a great day. Quote Link to comment https://forums.phpfreaks.com/topic/144779-solved-error-bad-parameters-with-php-mail-funtion-please-help/#findComment-760120 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.