1

メールを送信するPHP関数がありますが、

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

             $rec = $to.', '.$cc;

            $mail = $smtp->send($rec, $headers, $body, $cc);
        }
    }

関数を呼び出すと、$cc変数がない場合があるため、そのような警告が表示されますMissing argument 6 for sendemail(),

$cc が有効でない場合に警告を停止する最良の方法は何ですか?

4

4 に答える 4

1

これを使って

function sendemail($email_to,$email_from,$email_subject,$email_body,$email_replyto,$cc = "")
于 2013-09-05T10:16:51.993 に答える