HTF Posted November 15, 2009 Share Posted November 15, 2009 Hello, Welcome everybodey as I'm new on this forum. I have a few question regarding php code - form to email 1. I was testing a lot of php scripts and I have one that it's working now but unfortunately only with my domain email account but it's not with google acount or any other as I receive error: PHP Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for [email protected] in C:..... - this is big problem for me as I would like to use my gemail account How can I solve this? 2. How to prevent users from refreshing the form after it has been sent so I wouldn't receive more that one emails, I placed something like this in the php code: $stopRefresh = true; - but it didn't help 3. How to set image veryfication, is it a lot of work? The whole code is belowe and one more questions how it's work as I had to add all form fields IDs to all scripts that I tested before but this one picks up any form... <?php error_reporting(E_ALL ^ E_NOTICE); $my_email = "email"; $from_email = "email"; $continue = "/"; $errors = array(); // Remove $_COOKIE elements from $_REQUEST. if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}} // Display any errors and exit if errors exist. if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;} if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");} // Build message. function build_message($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)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");} $message = build_message($_REQUEST); $message = stripslashes($message); $subject = "Dark space Quary..."; $subject = stripslashes($subject); if($from_email) { $headers = "From: " . $from_email; $headers .= PHP_EOL; $headers .= "Reply-To: " . $_REQUEST['email']; } else { $from_name = ""; if(isset($_REQUEST['name']) && !empty($_REQUEST['name'])){$from_name = stripslashes($_REQUEST['name']);} $headers = "From: {$from_name} <{$_REQUEST['email']}>"; } mail($my_email,$subject,$message,$headers); $stopRefresh = true; //false; //true; ?> <html> <head> <title>Homepage</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- body { background-color: #f1f1f1; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; color: #666666; text-decoration: none; } --> </style> </head> <div> <div align="left">Thank you for your interest! Your email will be answered very soon!</div> </div> </body> </html> thanks for any help in advance. Reg Quote Link to comment https://forums.phpfreaks.com/topic/181602-form-to-email-code/ Share on other sites More sharing options...
cags Posted November 15, 2009 Share Posted November 15, 2009 I don't believe you can send an e-mail via G-mail using the mail function. I believe G-mail requires authentication, something which the mail function doesn't support. Quote Link to comment https://forums.phpfreaks.com/topic/181602-form-to-email-code/#findComment-957915 Share on other sites More sharing options...
HTF Posted November 15, 2009 Author Share Posted November 15, 2009 Thx for reply, Do you know how to solve it or maybe some ready script? - one more thing, I can set more than one emails as a recipients but do you know script that when people choose different department from the scroll down list in the form, an email will be sent acording of their choice Reg Quote Link to comment https://forums.phpfreaks.com/topic/181602-form-to-email-code/#findComment-957959 Share on other sites More sharing options...
Irresistable Posted November 15, 2009 Share Posted November 15, 2009 This was found on a tutorial, there for third party. Would I be right? I can always help you out with the captcha, once you get the mail working with all nessecary areas. Quote Link to comment https://forums.phpfreaks.com/topic/181602-form-to-email-code/#findComment-957960 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.