yii-extensionsmailerbcccarbon-copy

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


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 = 'feedback@balaee.com';
        $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?


Solution

  • According to the README.md on the original PHPMailer's Github home, you can just call $mailer->AddCC('recipient@example.com');. BCC is just as simple: $mailer->AddBCC('another_recipient@example.com');.

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