hosker Posted December 29, 2011 Share Posted December 29, 2011 I get the following warning when submitting a form. Up until yesterday the mail() function had no issues sending out the email. Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\6027795\html\demo\submit.php on line 125 Here is my code: <?php define('INCLUDE_CHECK',false); // require 'connect.php'; // require 'functions.php'; // Those two files can be included only if INCLUDE_CHECK is defined require_once './core/gear/SessionGear.php'; require_once './core/gear/UserProfileGear.php'; require_once './core/gear/SearchGear.php'; // This is required for Login status $accessrights=array ('s'); include 'defender.php'; // Gets the Current Logged in User $sessionid=''; if (isset($_COOKIE['sessionid'])) { $sessionid=$_COOKIE['sessionid']; } $userid= SessionGear::getInstance()->getUserForSession($sessionid); // Pulls out users email to store it in the form $sql="SELECT `username`,`role`,`status`,`fname`,`lname`,`email` FROM `clp_user` WHERE `username`='$userid'"; $userprof=mysql_query($sql); $countToCheck=0; if ($userprof) { $countToCheck=mysql_num_rows($userprof); } else { $countToCheck=0; } $userdetail=array("username"=>"","role"=>"","status"=>"", "fname"=>"","lname"=>"","email"=>""); if ($countToCheck) { while ($row=mysql_fetch_assoc($userprof)) { $userdetail['username']=$row['username']; $userdetail['role']=$row['role']; $userdetail['status']=$row['status']; $userdetail['fname']=$row['fname']; $userdetail['lname']=$row['lname']; $userdetail['email']=$row['email']; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to Chubsters Golf & Country Club</title> <link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" /> <link rel="stylesheet" media="all" type="text/css" href="css/index.css" /> </head> <body> <div id="header"> </div> <div> <?php include("includes/menu.php"); ?> </div> <?PHP /* Database config */ $db_host = ''; $db_user = ''; $db_pass = ''; $db_database = ''; /* End config */ $link = mysql_connect($db_host,$db_user,$db_pass) or die('Unable to establish a DB connection'); mysql_select_db($db_database,$link); mysql_query("SET player UTF8"); $usr = $userid; $golfer = $_REQUEST['golfer']; $tournament = $_REQUEST['tournament']; $backup = $_REQUEST['backup']; date_default_timezone_set('US/Eastern'); $time = date("Y-m-d H:i:s"); echo $t_id; echo "<br />"; echo $tournament; echo "<br />"; echo $usr; echo "<br />"; echo $golfer; echo "<br />"; echo $backup; echo "<br />"; echo $time; echo "<br />"; echo $userdetail['email']; echo "<br />"; //$sql = "SELECT * FROM weekly_picks WHERE tournament = '$tournament' AND usr = '$usr'"; //$result = mysql_query($sql); //echo mysql_num_rows($result); //if ($num > 0) // mysql_query("UPDATE weekly_picks SET player = '$golfer' WHERE tournament = '$tournament' AND user = '$usr'"); //else mysql_query("INSERT INTO weekly_picks (t_id, tournament, user, player, backup, timestamp) VALUES ('$t_id', '$tournament', '$usr', '$golfer', '$backup', '$time')",$link) or die('Error, insert query failed'); $to = $userdetail['email']; $subject = "Weekly Tournament Pick for: $tournament"; $message = "This email is to confirm your pick for $tournament has been received. Your pick is: $golfer. Your backup pick is: $backup The time it was submitted was $time Do not reply to this email, the mailbox does not exist. Contact me with any issues at [email protected]"; $from = "[email protected]"; $headers = "From:" . $from; mail($to,$subject,$message,$headers); ?> <div> <p>This is to confirm that your pick has been submitted for the following tournament: <?php echo $tournament; ?>. A confirmation of your pick as also been emailed to you.</p> <p>Your golfer: <?php echo $golfer; ?></p> <p>Your backup: <?php echo $backup; ?></p> <p>Your pick was submitted at: <?php echo $time; ?></p> </div> <div> <p>This is the footer</p> </div> </body> </html> Any ideas as to what I can do to fix this issue? I have hosting with GoDaddy on a windows hosting plan. Quote Link to comment https://forums.phpfreaks.com/topic/254027-php-mail-issue/ Share on other sites More sharing options...
AyKay47 Posted December 29, 2011 Share Posted December 29, 2011 something has changed in your code then, before I glance at your code I must ask, have you looked at the line of code that the error is referring to? have you tried using simple syntax to send mail to make sure that it is not an SMTP error? mail('[email protected]','subject','message'); Quote Link to comment https://forums.phpfreaks.com/topic/254027-php-mail-issue/#findComment-1302245 Share on other sites More sharing options...
hosker Posted December 29, 2011 Author Share Posted December 29, 2011 I used your suggestion and it sent the email. Quote Link to comment https://forums.phpfreaks.com/topic/254027-php-mail-issue/#findComment-1302252 Share on other sites More sharing options...
AyKay47 Posted December 29, 2011 Share Posted December 29, 2011 then you know that it is not an SMTP server error, but a user error. the first step in debugging this will be to look at the line referenced in the error message for any errors. Quote Link to comment https://forums.phpfreaks.com/topic/254027-php-mail-issue/#findComment-1302256 Share on other sites More sharing options...
hosker Posted December 29, 2011 Author Share Posted December 29, 2011 The line is: mail($to,$subject,$message,$headers); I do not see any errors. Quote Link to comment https://forums.phpfreaks.com/topic/254027-php-mail-issue/#findComment-1302270 Share on other sites More sharing options...
peter_anderson Posted December 29, 2011 Share Posted December 29, 2011 When you have a new line within the email, try using \r\n Quote Link to comment https://forums.phpfreaks.com/topic/254027-php-mail-issue/#findComment-1302271 Share on other sites More sharing options...
hosker Posted December 29, 2011 Author Share Posted December 29, 2011 So I broke up the forma and put each line into its own variable and put in the following code between each variable: ."\r\n". the form now sends the email, but the email is all one line. Quote Link to comment https://forums.phpfreaks.com/topic/254027-php-mail-issue/#findComment-1302285 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.