3

私はこのPHPメール機能を持​​っています:

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);
        }
    }
}

メールアドレスをCCする機能を追加しました:

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);
        }
    }
}

ただし、CC された電子メール アドレスをヘッダーに追加するだけで、電子メールは送信されないようです。$email_to 変数のアドレスにのみメールを送信します

CCを機能させる方法はありますか?

4

1 に答える 1