email - PHP Mail adding CC -


i have php mail function:

if(!function_exists("sendemail")) {     function sendemail($email_to,$email_from,$email_subject,$email_body,$email_replyto)     {         if(filter_var($email_to, filter_validate_email))         {             require_once "/usr/local/lib/php/mail.php";              $from = $email_from;             $to = $email_to;             $subject = $email_subject;             $body = $email_body;              $host = "mail.domain.co.uk";             $username = "sending@domain.co.uk";             $password = "*******";              $headers = array ('from' => $from,               'to' => $to,               'subject' => $subject,               'content-type' => 'text/html');             $smtp = mail::factory('smtp',               array ('host' => $host,              'auth' => true,              'username' => $username,              'password' => $password));              $mail = $smtp->send($to, $headers, $body, $cc);         }     } } 

i have added in ability cc email addresses in:

if(!function_exists("sendemail")) {     function sendemail($email_to,$email_from,$email_subject,$email_body,$email_replyto,$cc)     {         if(filter_var($email_to, filter_validate_email))         {             require_once "/usr/local/lib/php/mail.php";              $from = $email_from;             $to = $email_to;             $subject = $email_subject;             $body = $email_body;              $host = "mail.domain.co.uk";             $username = "sending@domain.co.uk";             $password = "*******";              $headers = array ('from' => $from,               'to' => $to,               'cc' => $cc,               'subject' => $subject,               'content-type' => 'text/html');             $smtp = mail::factory('smtp',               array ('host' => $host,              'auth' => true,              'username' => $username,              'password' => $password));              $mail = $smtp->send($to, $headers, $body, $cc);         }     } } 

but seems add cc'd email address(es) header , not send email. sends email address in $email_to variable

any ideas how can cc working?

i'm assuming using pear class mail, if not disregard.

according (http://pear.php.net/manual/en/package.mail.mail.send.php#2073) need have email address want cc in receipients , headers. have never used code can't attest whether works or not.

here link saying same thing: http://raamdev.com/2008/adding-cc-recipients-with-pear-mail/

pulled link:

$to = 'to@example.com'; $cc = 'cc@example.com'; $recipients = $to.", ".$cc; $headers['from']    = 'from@example.com'; $headers['to']      = $to; $headers['subject'] = 'test message'; $headers['cc']      = 'cc@example.com'; $headers['reply-to'] = 'from@example.com';  $send = $mail->send($recipients, $headers, $body); 

also in case ever need according link bcc add email address $recipients , don't add $headers.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -