mathan5481 Posted April 6, 2014 Share Posted April 6, 2014 i need to send a copy of the form to the sender as well as to myself..i can receive email to my own email but not a copy to the sender... how do i go about it? plz help this is the code <?php $to = '[email protected]'; $subject = 'Order Form'; $msg = "<html><body> <b>Name : " . strip_tags($_POST['name']) . " </b><br><br> <b>Tel No. : " . strip_tags($_POST['phone']) . " </b><br><br> <b>E-Mail : " . strip_tags($_POST['email']) . " </b><br><br> <b>Address : " . strip_tags($_POST['add']) . " </b><br><br> <b>Messages : " . strip_tags($_POST['messages']) . " </b><br><br> </body> </html>"; // Make sure to escape quotes $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From <[email protected]>' . "\r\n"; mail($to, $subject, $msg, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/287556-sending-a-copy-of-mail-to-sender/ Share on other sites More sharing options...
trq Posted April 6, 2014 Share Posted April 6, 2014 What have you tried? Link to comment https://forums.phpfreaks.com/topic/287556-sending-a-copy-of-mail-to-sender/#findComment-1475112 Share on other sites More sharing options...
mathan5481 Posted April 6, 2014 Author Share Posted April 6, 2014 i checked in few sites and added few lines, but it dont seems to work.. <?php $to = '[email protected]'; $Cc = '($_POST['email']) '; $subject = 'Order Form'; $msg = "<html><body> <b>Name : " . strip_tags($_POST['name']) . " </b><br><br> <b>Tel No. : " . strip_tags($_POST['phone']) . " </b><br><br> <b>E-Mail : " . strip_tags($_POST['email']) . " </b><br><br> <b>Address : " . strip_tags($_POST['add']) . " </b><br><br> <b>Messages : " . strip_tags($_POST['messages']) . " </b><br><br> </body> </html>"; // Make sure to escape quotes $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From <[email protected]>' . "\r\n"; mail($to, $Cc, $subject, $msg, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/287556-sending-a-copy-of-mail-to-sender/#findComment-1475114 Share on other sites More sharing options...
trq Posted April 6, 2014 Share Posted April 6, 2014 Variables are not interpolated within single quotes. Link to comment https://forums.phpfreaks.com/topic/287556-sending-a-copy-of-mail-to-sender/#findComment-1475116 Share on other sites More sharing options...
mathan5481 Posted April 6, 2014 Author Share Posted April 6, 2014 sorry i dont understand.. can elaborate plz? Link to comment https://forums.phpfreaks.com/topic/287556-sending-a-copy-of-mail-to-sender/#findComment-1475117 Share on other sites More sharing options...
davidannis Posted April 6, 2014 Share Posted April 6, 2014 $Cc = '($_POST['email']) '; is in single quotes you need: $Cc = "{$_POST['email']} "; or it tries to cc $_POST['emai'] instead of whatever address is stored in that variable. Link to comment https://forums.phpfreaks.com/topic/287556-sending-a-copy-of-mail-to-sender/#findComment-1475128 Share on other sites More sharing options...
DavidAM Posted April 7, 2014 Share Posted April 7, 2014 mail($to, $Cc, $subject, $msg, $headers); You can't just add parameters to a function call. You need to put the CC as a header: $headers .= "Cc: <[email protected]>\r\n"; Keep in mind. When you do that, whoever you are sending the CC to will see YOUR email address as well. If you want to prevent that, send it TO: the user and BCC: to your email. Link to comment https://forums.phpfreaks.com/topic/287556-sending-a-copy-of-mail-to-sender/#findComment-1475184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.