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("webmaster@edgwaretown.co.uk", $subject, $message, $from); ?> How can I get the user to get the data by email as well? Thanks Gary Quote 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. Quote 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("webmaster@town.co.uk", $subject, $message, $from); Quote 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 Quote 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("webmaster@edgwaretown.co.uk", $subject, $message, $from); ?> Quote 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] Quote 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("webmaster@edgwaretown.co.uk", $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("webmaster@town.co.uk", $subject, $message, $from); ?> Quote 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? Quote 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("webmaster@edgwaretown.co.uk", $subject, $message, $from, $Cc); Quote 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 Quote 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("webmaster@edgwaretown.co.uk", $subject, $message, $from, $Cc); You don't add $Cc in the mail() function, the Cc header is already in the $from variable . . . Quote Link to comment https://forums.phpfreaks.com/topic/219108-send-mail-form-php/#findComment-1136286 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.