jalen Posted June 11, 2009 Author Share Posted June 11, 2009 madtechie walk me through on how to get it to work Link to comment https://forums.phpfreaks.com/topic/160423-form-to-mail/page/4/#findComment-853407 Share on other sites More sharing options...
jalen Posted June 11, 2009 Author Share Posted June 11, 2009 I like to get local environment to work is because I like to do testing, is easier to do testing this way. Link to comment https://forums.phpfreaks.com/topic/160423-form-to-mail/page/4/#findComment-853464 Share on other sites More sharing options...
jalen Posted June 11, 2009 Author Share Posted June 11, 2009 madtechie, this code works on my hosting site: but not local environment, on local environment i always get this error: Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Apache\htdocs\FormToEmail.php on line 89 failed <html> <head> <title>Untitled 2</title> </head> <body> <form action="FormToEmail.php" method="post"> <table border="1" bgcolor="#ececec" cellspacing="5"> <tr><td>Email address</td><td><input type="text" size="30" name="my_email"></td></tr> <tr><td>Name</td><td><input type="text" size="30" name="name"></td></tr> <tr><td>Email address</td><td><input type="text" size="30" name="email"></td></tr> <tr><td valign="top">Comments</td><td><textarea name="comments" rows="6" cols="30"></textarea></td></tr> <tr><td> </td><td><input type="submit" value="Send"><font face="arial" size="1"> <a href="http://FormToEmail.com">Form Mail</a> by FormToEmail.com</font></td></tr> </table> </form> </body> </html> <?php ini_set("display_errors", "1"); error_reporting(E_ALL); $my_email = '[email protected]'; $errors = array(); // Check for a blank form. //function recursive_array_check_blank($element_value) function blank($fillin) { //is_array — Finds whether a variable is an array global $set; if(!is_array($fillin)){ if(!empty($fillin)){ $set = 1; } }else{ foreach($fillin as $value){ if($set){ break; } blank($value); } } } blank($_REQUEST); if(!$set){ $errors[] = "You cannot send a blank form"; } unset($set); // Display any errors and exit if errors exist. if(count($errors)){ foreach($errors as $value){ print "$value<br>"; } exit; } // Build message. function Comment_text($request_input){ if(!isset($message_output)){ $message_output =""; } if(!is_array($request_input)){ $message_output = $request_input; }else{ foreach($request_input as $key => $value){ if(!empty($value)){ if(!is_numeric($key)){ $message_output .= str_replace("_"," ",ucfirst($key)).": ".Comment_text($value).PHP_EOL.PHP_EOL; }else{ $message_output .= Comment_text($value).", "; } } } }return rtrim($message_output,", "); } $message = Comment_text($_REQUEST); $message = stripslashes($message); $subject = "Comment have been added to your YYTgen contribution report!"; $headers = "From: " . $_REQUEST['email']; if (mail($my_email,$subject,$message,$headers)) { echo "sent"; }else{ echo "failed"; } ?> <html> <head> <title>Form To Email PHP script from FormToEmail.com</title> </head> <body bgcolor="#ffffff" text="#000000"> <div> <center> <b>Thank you <?php print stripslashes($_REQUEST['name']); ?></b> <br>Your message has been sent </center> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/160423-form-to-mail/page/4/#findComment-853524 Share on other sites More sharing options...
cs.punk Posted June 14, 2009 Share Posted June 14, 2009 LoL this post is way funny! Link to comment https://forums.phpfreaks.com/topic/160423-form-to-mail/page/4/#findComment-855770 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.