Jump to content

email CGI-Mailer


DezB1

Recommended Posts

Hi Folks

 

I'm relatively new to PHP so please excuse my ignorance where it shows through.

 

I have a contact form on a website that sends perfectly well but when it is received the "From" box shows "CGI-Mailer"  I would like to replace that with the senders email address that they have to enter on the contact form if at all possible.

 

The code I am using is:

 

 
<?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'])) ) {
mail("[email protected]","Blah Blah - Website Contact","Contact Form Data:

Title: " . $_POST['field_1'] . "
First Name: " . $_POST['field_2'] . "
Last Name: " . $_POST['field_3'] . "

Your email address: " . $_POST['field_4'] . "

Your phone number: " . $_POST['field_5'] . "

Message: " . $_POST['field_6'] . "



");

include("confirm.html");
}
else {
echo "Invalid Captcha String.";
}

?>
 

Any help would be most appreciated, thank you

 

DezB1

Link to comment
https://forums.phpfreaks.com/topic/296009-email-cgi-mailer/
Share on other sites

This information comes from the php manual for mail here -> http://php.net/manual/en/function.mail.php. Did you read that?

 

$headers = 'From: ' . $_POST['field_4'] . "\r\n" .
    'Reply-To: ' . $_POST['field_4'] . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

These additional headers can be sent as an optional parameter to mail().

 

So your code would probably be:

 

$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();


mail("[email protected]","Blah Blah - Website Contact","Contact Form Data:

Title: " . $_POST['field_1'] . "
First Name: " . $_POST['field_2'] . "
Last Name: " . $_POST['field_3'] . "

Your email address: " . $_POST['field_4'] . "

Your phone number: " . $_POST['field_5'] . "

Message: " . $_POST['field_6'] . "



", $headers);
Link to comment
https://forums.phpfreaks.com/topic/296009-email-cgi-mailer/#findComment-1510526
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.