Page 1 of 1

Changing the client email address when sending form data

Posted: Sat Jun 28, 2008 4:26 am
by lhcpr
Hello all - just FYI: total php newbie.

I have been using phpformgenerator (sourceforge project) to design a form and php code. Everything seems to work just fine. The form data is designed to be sent to an email recipient (x@yahoo.com).

BUT... when the form data is received by the recipient, the senders email address is xyz@domainhost.com. What I wish to do is change the sender/from address (i.e currently xyz@domainhost.com) to something like xyz@gmail.com. The reason why I wish to do this is that becasue when my email receives the form data by email, it is identified as spam / junk. I have posted my code and the output below.

Is there any way I can change the address that sends the form data (in line with the above)?

Thanks

Graham

Code: Select all

<?php 
 
$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
 
session_start();
if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) { 
// Checkbox handling
$field_5_opts = $_POST['field_5'][0];
// the value of $_POST['field_6'] is xyz@gmail.com
$email = $_POST['field_6'];
 
mail("x@yahoo.com","No development at Turrella Reserve","Form data: 
 
" . $_POST['field_1'] . " " . $_POST['field_2'] . " says no to development at Turrella Reserve" . "
Email address: " . $_POST['field_3'] . "
This is what " . $_POST['field_1'] . " has to say: 
" . $_POST['field_4'] . "
Check if you wish to receive updates on development progress: $field_5_opts ",$email);
 
include("confirm.html");
}
else {
echo "Invalid Captcha String.";
}
 
?>
----------------------------------------------------------------------------------------------

The output is:

x@gmail.com

Form data:

Kittles Smith says no to development at Turrella Reserve
Email address: kittles@buchanan.com
This is what Kittle has to say:
fjeskfjdks
Check if you wish to receive updates on development progress: Yes