/    Sign up×
Community /Pin to ProfileBookmark

Contact form – Want users email address to show "sent from"

Hi

I have a contact from which works fine and sends an email to my email address but its always showing send from “[email protected]” which is my hosting provider. How do I get the email to show its been sent from the email address thats entered on contact from?

code is

[CODE]<?php
/*** ———- CHANGE THIS TO YOUR EMAIL ADDRESS ————- ***/
$MAIL_TO = ‘[email protected]’;

/*** ———————————————————- ***/

$subject = “Web Site Take The Test :: GG”;
$time = date(‘d-m-Y H:i’);

$fname = $_POST[‘fname-field’];
$telephone1 = $_POST[‘telephone1-field’];
$telephone2 = $_POST[‘telephone2-field’];
$mail = $_POST[‘mail-field’];
$address = $_POST[‘address-field’];
$postcode = $_POST[‘postcode-field’];
$debts = $_POST[‘debt-field’];
$creditors = $_POST[‘creditors-field’];
$message = $_POST[‘message-field’];

$name = $fname . ‘ ‘ . $lname;

$body = “Take The Test Sent: $timenn”;
$body .= “Name: $namenTelephone1: $telephone1nTelephone2: $telephone2nEmail: $mailnnAddress:n$addressnPost Code: $postcodennHow Debts ?: $debtsnHow many creditors: $creditorsnn”;
$body .= “Message:n$message”;

@mail($MAIL_TO, $subject, $body);
echo ‘sent!’;
?>[/CODE]

any help would be great, thanks

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 07.2012 — [code=php]
$headers = "Reply-To: " . filter_var($mail, FILTER_SANITIZE_EMAIL);
mail($MAIL_TO, $subject, $body, $headers);
[/code]
Copy linkTweet thisAlerts:
@hyperionXSMar 07.2012 — From http://php.net/mail
[code=php]
$headers = 'From: [email protected]' . "rn" .
'X-Mailer: PHP/' . phpversion();

mail($MAIL_TO, $subject, $body, $headers);
[/code]
×

Success!

Help @rashriaz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...