Jump to content

Form to email code...


HTF

Recommended Posts

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.