csramin Posted May 8, 2007 Share Posted May 8, 2007 *Disclaimer: I don't know much (almost nothing) about PHP. Please use small words . I created a Simple Feedback (mail) form in PHP, by following instructions in a book. It's pretty standard: User fills out form on website. Information gets send to mailbox. It works almost perfectly. The only thing I need to do is get the "From:" portion of the email to change to the users email address. Right now any email that comes from a form on the site has "mysite"@box143.bluehost.com as the sender. Its kind of like a default box or something. Anyway, Is there a standard command (i.e. $to = "", $subject = "") that I can use to change this like I did with the "Subject:"? <? $msg .= "PERSONAL INFO\n"; $msg .= "Name: $_POST[name] \n"; $msg .= "Company: $_POST[company] \n"; $msg .= "Phone: $_POST[phone] \n"; $msg .= "Email: $_POST[email] \n\n"; $msg .= "City: $_POST[city] \n"; $msg .= "State: $_POST[state] \n"; $msg .= "Zip Code: $_POST[zip] \n"; $msg .= "Country: $_POST[country] \n\n"; $msg .= "MESSAGE: $_POST[message] \n\n"; $to = "info@mysite.com"; $subject = "Contact"; mail($to, $subject, $msg, $mailheaders); ?> PLEASE HELP! Quote Link to comment https://forums.phpfreaks.com/topic/50570-solved-change-from-portion-of-email/ Share on other sites More sharing options...
cunoodle2 Posted May 9, 2007 Share Posted May 9, 2007 Here you go. You never set a value for the variable "$mailheaders". You can use this 4th parameter to specify from, CC and BCC. Also if you are sending HTML (so NON plain text e-mails) from the script you can use this header variable to specify another "to" address... $mailheaders = 'From: Your Website <csramin@csramin.com>' . "\r\n"; $mailheaders .= 'Cc: address2@csramin.com' . "\r\n"; $mailheaders .= 'Bcc: another-address-here@csramin.com' . "\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/50570-solved-change-from-portion-of-email/#findComment-248626 Share on other sites More sharing options...
csramin Posted May 9, 2007 Author Share Posted May 9, 2007 That worked very nicely. It changed the "From:" portion of the email, but there's still a problem What I need to change it to is the senders email. $mailheaders = 'From: $_POST[email] <contact@csramin.com>' . "\r\n"; $mailheaders .= 'Cc: address2@csramin.com' . "\r\n"; $mailheaders .= 'Bcc: another-address-here@csramin.com' . "\r\n"; I totally made that code up and no it didn't work and you probably know why and are either shaking your head or laughing. That's okay. My logic obviously isn't very PHP savvy. I think you get what I'm trying to do though. How do I get this to work? PS I can get the "Reply-To:" to work. Thats not the issue. Quote Link to comment https://forums.phpfreaks.com/topic/50570-solved-change-from-portion-of-email/#findComment-249142 Share on other sites More sharing options...
csramin Posted May 9, 2007 Author Share Posted May 9, 2007 *bump I know you want to help me... Quote Link to comment https://forums.phpfreaks.com/topic/50570-solved-change-from-portion-of-email/#findComment-249330 Share on other sites More sharing options...
grimmier Posted May 9, 2007 Share Posted May 9, 2007 what about this? $mailheaders = 'From: <'.$_POST['email'].'>' . "\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/50570-solved-change-from-portion-of-email/#findComment-249396 Share on other sites More sharing options...
csramin Posted May 9, 2007 Author Share Posted May 9, 2007 Thanks to grimmier and cunoodle2. It works perfectly!! Quote Link to comment https://forums.phpfreaks.com/topic/50570-solved-change-from-portion-of-email/#findComment-249417 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.