ghi572000 Posted November 18, 2010 Share Posted November 18, 2010 I am trying to send the data entered in to the form to myself and to the user. At the moment I am getting the data sent to myself but cant find the way to send it to the user. I am using this code below <?php mail("[email protected]", $subject, $message, $from); ?> How can I get the user to get the data by email as well? Thanks Gary Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/ Share on other sites More sharing options...
Pikachu2000 Posted November 18, 2010 Share Posted November 18, 2010 One way would be to add a Cc: email header. Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/#findComment-1136216 Share on other sites More sharing options...
ghi572000 Posted November 18, 2010 Author Share Posted November 18, 2010 Pikachu2000 thanks could you show me where and how to add this to my code? mail("[email protected]", $subject, $message, $from); Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/#findComment-1136223 Share on other sites More sharing options...
Rifts Posted November 18, 2010 Share Posted November 18, 2010 you need to "capture" the users email using a form Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/#findComment-1136224 Share on other sites More sharing options...
ghi572000 Posted November 18, 2010 Author Share Posted November 18, 2010 I am able to capture the users email in the form as $visitormail = $_POST['visitormail']; How can I add the user visitormail to send as mail? <?php mail("[email protected]", $subject, $message, $from); ?> Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/#findComment-1136228 Share on other sites More sharing options...
Pikachu2000 Posted November 18, 2010 Share Posted November 18, 2010 You'd just need to concatenate it to your $from variable, since that's the one that would hold additional headers for the mail() function. So to whatever that variable holds now you'd add a newline \n, then the Cc. $sender = (sender's email address); $from = "whatever it is now\n"; $from .= "Cc: $sender"; [/code] Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/#findComment-1136229 Share on other sites More sharing options...
ghi572000 Posted November 18, 2010 Author Share Posted November 18, 2010 This is what I have now; $message = " $todayis [EST] \n Subject: $subject \n From: $visitor \n Email: $visitormail)\n Phone: $phone \n IP Address: IP = $ip \n "; $from = "From: $visitormail\r\n"; mail("[email protected]", $subject, $message, $from); ?> Will this work or have I still got it wrong? $message = " $todayis [EST] \n Subject: $subject \n From: $visitor \n Email: $visitormail)\n Phone: $phone \n IP Address: IP = $ip \n "; $from = "From: $visitormail\r\n"; $from .= "Cc: $visitormail\r\n"; mail("[email protected]", $subject, $message, $from); ?> Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/#findComment-1136233 Share on other sites More sharing options...
Pikachu2000 Posted November 18, 2010 Share Posted November 18, 2010 That looks like it should be fine. Did you try it? Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/#findComment-1136241 Share on other sites More sharing options...
ghi572000 Posted November 18, 2010 Author Share Posted November 18, 2010 yes I tried it but no luck? should I add cc as followed? $from = "From: $visitormail\r\n"; $from = "Cc: $visitormail\r\n"; mail("[email protected]", $subject, $message, $from, $Cc); Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/#findComment-1136274 Share on other sites More sharing options...
ghi572000 Posted November 18, 2010 Author Share Posted November 18, 2010 Okay thanks Pikachu2000 I have got it to work without the Cc in the mail code, however one more problem I need to solve is the Cc mail is being sent from my ISP servers address not mine? Do you know a way I can get the mail sent from my email address? Thanks Gary Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/#findComment-1136282 Share on other sites More sharing options...
Pikachu2000 Posted November 18, 2010 Share Posted November 18, 2010 yes I tried it but no luck? should I add cc as followed? $from = "From: $visitormail\r\n"; $from = "Cc: $visitormail\r\n"; mail("[email protected]", $subject, $message, $from, $Cc); You don't add $Cc in the mail() function, the Cc header is already in the $from variable . . . Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/#findComment-1136286 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.