Jump to content

Php form: sent email has server email address as sender


gabk77

Recommended Posts

Hi

This should be a simple thing but I can't find info on this. I've set up my php form and everything is fine. When the email is received in an email program in the header it shows that the form was sent from the server. I'd like to change this so that the from email address is the one the user entered on the php form. What kind of variable name do I need for this and where do I put it? Could you give me an example? I'm able to modify the subject line and I'm sure it's something along those lines.

Thanks.
[code]<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
  'Reply-To: [email protected]' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>[/code]

if you want the email to be from the person that entered information into the form just substitue your variable for the '[email protected]'
Thank you very much!! That helped.

I couldn't just replace your example email address. I had to do the following to make it work.

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

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.