srcfresno Posted August 26, 2011 Share Posted August 26, 2011 I get this error message and no email when I test this form Warning: mail() [function.mail]: Failed to connect to mailserver at "127.0.0.1" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() ini_set() in \\boswinfs02\home\users\web\b1835\ez.srcfresnocom\PCHSubscomplete.php on line 28 Line 28 is the $send = and the web address is assigned by the webhosting service. Is the problem with my mail function code? <?php $to = '[email protected]'; $subject = 'PCH subs'; if (get_magic_quotes_gpc()) { $_POST = array_map('stripslashes',$_POST); } $fields = array( 'firstname' => 'First Name', 'lastname' => 'Last Name', 'email' => 'Email', 'phone' => 'Phone', 'muchspend' => 'How much did you spend on your purchase today?' ); $body = "PCH subs:\n\n"; foreach($fields as $a => $b) { if(array_key_exists($a,$_POST)) { $body .= sprintf("%s: %s\n",$b,$_POST[$a]); } } $send = mail($to, $subject, $body); if($send) {print ""; } else {print "We encountered an error sending your mail, please notify [email protected]"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/245729-mail-function-error/ Share on other sites More sharing options...
pengu Posted August 26, 2011 Share Posted August 26, 2011 It doesn't appear to have anything to do with the mail() function. Echo out $body to make sure there is no errors with it. Seems to be an error with your hosting. Quote Link to comment https://forums.phpfreaks.com/topic/245729-mail-function-error/#findComment-1262117 Share on other sites More sharing options...
srcfresno Posted August 26, 2011 Author Share Posted August 26, 2011 Thank you. I kinda thought so but wanted to run by the experts. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/245729-mail-function-error/#findComment-1262124 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.