send email through php script, add "cc "

Discussion in 'Site Programming, Development and Design' started by Wenhu Tong, May 11, 2018.

  1. I have following php script through which I can send out email. Now I want to add "CC", copy to another email address, Can somebody give me a hint? Thanks.

    <head><title>Test email via php</title></head>
    require_once "Mail.php";
    $from = "Sender <>";
    $to = "Recipient <>";
    $subject = "This is a test email sent via php";
    $body = "This is a test email";
    $host = "";
    $username = "";
    $password = "**********";
    $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);
    $smtp = Mail::factory('smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));
    $mail = $smtp->send($to, $headers, $body);

Share This Page