How to include "cc" and "bcc" fields using mailer extension of Yii Framework

4k views Asked by At

I am working on mail sending functionality using yii framework. I am using mailer extension given on link="http://www.yiiframework.com/extension/mailer". I have added all files in extension folder. And i have made separate class file with code as-

 public function sendEmail($FromEmail,$ToEmail,$Subject,$Message)
    {
        $settings=new Settings();
        $mailer = Yii::createComponent('application.extensions.mailer.EMailer');
        $mailer->IsSMTP();
        $mailer->IsHTML(true);
        $mailer->SMTPAuth = true;
        $mailer->SMTPSecure = 'ssl';
        $mailer->Host =$settings->Host;
        $mailer->Port =$settings->Port;
        $mailer->CharSet = 'UTF-8';
        $mailer->Username =$FromEmail; 
        $mailer->Password ='';
        $mailer->FromName = '[email protected]';
        $mailer->AddAddress($ToEmail);
        $mailer->Subject = $Subject;
        $mailer->IsHTML(true);
        $mailer->Body=$Message;
        if($mailer->Send())
        {
            echo "Mail send Successfully.Please you have check mail ";
        }
        else
        {
            echo "Fail to send your message!";
        }
    }

So its working correctly. Its sending emails as per required. But i want include "cc" and "bcc" parameters while using this in order to maintain security. So how can i use "cc" and "bcc" using mailer extension?

1

There are 1 answers

0
kekkis On BEST ANSWER

According to the README.md on the original PHPMailer's Github home, you can just call $mailer->AddCC('[email protected]');. BCC is just as simple: $mailer->AddBCC('[email protected]');.

The reason I am referring to PHPMailer is that the yii extension page does so too.