How To Send Email To User Fron Site

Plz any body could explain how send email in yii,do we need to save any library for mail,plz i want full functionality.

Is google broken again?

You should download http://www.yiiframework.com/extension/mailer/

and then …




public function connectToMailServer()

    {

        $this->mailer = Yii::createComponent('application.extensions.mailer.EMailer');

        $this->mailer->IsSMTP();

        $this->mailer->SMTPDebug = 1;

        $this->mailer->SMTPKeepAlive = true;

        $this->mailer->Host = 'mail.xxx.com';

        $this->mailer->Username = 'xxx';

        $this->mailer->Password = 'xxx';

        $this->mailer->SMTPSecure = "tls";

        $this->mailer->SetFrom('xxx@xxx.com');

        $this->mailer->AddReplyTo('xxx@xxx.com');

    }


    public function email($subject, $recipients, $content, $id, $emailType=1) 

    {

        $emails = explode(";", $recipients);

        foreach($emails as $email) {

            $this->mailer->AddAddress($email);

        }


        $this->mailer->FromName = 'xxx';

        $this->mailer->CharSet = 'UTF-8';


        if ($emailType == 1) { //attachment

            $this->mailer->Subject = "xxx";

            $filename = $this->createXMLFile($content,$id);

            $this->mailer->AddAttachment($filename);

            $this->mailer->Body = 'something is attached';

        } elseif ($emailType == 2) { //just an email - no attachment

            echo 'a notification';

            $this->mailer->Subject = "xxx";

            $this->mailer->Body = $content;

        }


        $this->mailer->Send();

        $this->mailer->ClearAddresses();

        $this->mailer->ClearAttachments();


    }



And Usage is




    public function actionSendReports()

    {

        $model = ReportOut::model()->findAllByAttributes(array("Processed"=>NULL)); //this is just a table i had where msgs were queued to be sent

        $this->connectToMailServer();


        foreach ($model as $row) {

            $recipients = $row->Recipients;


            $emails = explode(";", $recipients);


            $this->email($row->reportType->ReportTypeName, $recipients, $row->XMLMessage, $row->ReportOutID, 1);


        }


        $this->mailer->SmtpClose();

    }




Hope it helps …

I used this extension http://www.yiiframework.com/extension/mail/ a few days ago and I made it work pretty easy.