gabk77 Posted November 9, 2006 Share Posted November 9, 2006 HiThis 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. Link to comment https://forums.phpfreaks.com/topic/26654-php-form-sent-email-has-server-email-address-as-sender/ Share on other sites More sharing options...
pikemsu28 Posted November 9, 2006 Share Posted November 9, 2006 [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]' Link to comment https://forums.phpfreaks.com/topic/26654-php-form-sent-email-has-server-email-address-as-sender/#findComment-121940 Share on other sites More sharing options...
gabk77 Posted November 9, 2006 Author Share Posted November 9, 2006 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(); Link to comment https://forums.phpfreaks.com/topic/26654-php-form-sent-email-has-server-email-address-as-sender/#findComment-121946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.