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.

    <html>
    <head><title>Test email via php</title></head>
    <body>
    <?php
    require_once "Mail.php";
    $from = "Sender <[email protected]>";
    $to = "Recipient <[email protected]>";
    $subject = "This is a test email sent via php";
    $body = "This is a test email";
    $host = "mail.canadasmallbusiness.org";
    $username = "[email protected]";
    $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);
    ?>
    </body>
    </html>
     

Share This Page