mailer.php help

Hi there I have a fairly simple mailer php

[php]<?php
require_once(‘recaptchalib.php’);
$privatekey = “*******”;
$resp = recaptcha_check_answer ($privatekey,
$_SERVER[“REMOTE_ADDR”],
$_POST[“recaptcha_challenge_field”],
$_POST[“recaptcha_response_field”]);
if(!$resp->is_valid) {
header(“location:error.php”);
die();
}

$ip = $_SERVER[‘REMOTE_ADDR’];
$name = $_POST[‘name’];
$email = $_POST[‘email’];
$type = $_POST[‘type’];
$contact = $_POST[‘contact’];
$message1 = $_POST[‘message1’];
$formsub = $_POST[‘Submit’];

if($formsub){

$mailMessage = “Invitation Request\n\n”;
$mailMessage .= “IP: " .$ip.”\n\n";
$mailMessage .= “Desired Username: " .$name.”\n\n";
$mailMessage .= “E-Mail :” .$email."\n\n";
$mailMessage .= “Alt Contact: " .$type.”\n\n";
$mailMessage .= “” .$contact."\n\n";
$mailMessage .= “Comments: " .$message1.”\n\n";
$header = "From:[email protected]\r\n";
$header .= “Reply-To: [email protected]\r\n”;
$header .= “Return-Path: [email protected]\r\n”;
mail(‘[email protected]’, ‘Request Form’, $mailMessage,$header);

header(“location:thanks.php”);
exit;

}
?> [/php]

It works perfectly, what i want to do though is try and make
“$header = "From:[email protected]\r\n”;" and
"$header .= “Reply-To: [email protected]\r\n” link with

“$email = $_POST[‘email’];” so that both from and reply to show the email the person entered in my form.

Also how would I go about changing the subject of the form, at the moment it is “Request Form” is there a way to make it “Request Form - ( $name = $_POST[‘name’]; )” This last one isn’t as vital as the top one.

Any help is appreciated.

Hello Swaino, for modify headers and the subject line your below code and use code modify by me [php] //Remove this code $header = "From:[email protected]\r\n"; $header .= "Reply-To: [email protected]\r\n"; $header .= "Return-Path: [email protected]\r\n"; mail('[email protected]', 'Request Form', $mailMessage,$header); [/php]

use my modified code

[php]
//use this code instead of above code(or your old code)
$header = “From:$email\r\n”;
$header .= “Reply-To:$email\r\n”;
$header .= “Return-Path:$email\r\n”;
$subject_line = ‘Request Form - (’.$name.’)’;
mail(‘[email protected]’, $subject_line, $mailMessage, $header);
[/php]

i hope this will helpful for you.
Reply your feedback
SR

I registered to say thanks :slight_smile: Worked like charm, I did mess around with $email and $name but must of been doing it wrong.

Hello Swaino, it's really nice that your issue issue is resolve. i think i will get a karma point from you.. :D :D :D :) Enjoy... ~~SR~~
Sponsor our Newsletter | Privacy Policy | Terms of Service