email - Adding Cc to PHP mail -
so mailing contents of form client , person sent form cc'd in.
i have done research , appears need use header
code set from, subject , cc code set differently - please see below:
<?php $relatedproduct = $_post['related-product']; $name = $_post['name']; $phone = $_post['phone']; $email = $_post['email']; $message = $_post['message']; $formcontent="from: $name \n phone: $phone \n about: $relatedproduct \n message: $message"; $recipient = "email@mydomain.com"; $subject = "more information regarding $relatedproduct"; $mailheader = "from: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("error!"); header('location: ' . $_server['http_referer']); ?>
would possible this?
<?php $relatedproduct = $_post['related-product']; $name = $_post['name']; $phone = $_post['phone']; $email = $_post['email']; $message = $_post['message']; $to = $_post['email']; $subject = "more information regarding $relatedproduct"; $formcontent="from: $name \n phone: $phone \n about: $relatedproduct \n message: $message"; $headers .= 'cc: birthdayarchive@example.com' . "\r\n"; // mail mail($to, $subject, $formcontent, $headers); ?>
yes, have it:
... $headers .= 'from: birthday reminder <birthday@example.com>' . "\r\n"; $headers .= 'cc: birthday@example.com' . "\r\n"; mail($to, $subject, $content, $headers); ?>
incidentally, please sanitise post variables before inject them (e.g. $to = $_post['email'];
).
as @rhopercy says in comment, perhaps email library takes care of things you. take @ phpmailer or swiftmail.
Comments
Post a Comment