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@google.com 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