Yii SMTP Mail Extension

I created one extension to sent the mail using smtp methos. Just add it into your yii project and configure in main.php and send mail.

Download And Add SMTP Extension

Please Download the smtp mail extension and add it into protected/extension folder.
SMTP Mail Extension

SMTP Details in config/main.php

After added smtpmail extension file into extension folder, We have to give the set of details like Hostname, Username, Password, Mailer option, Port and SMTPAuth. We must have to configure this details in main.php before send the mail using this extension. I added the code below

            'Username'=>'[email protected]',

SMTP Mail Function

Using this function we can send the mail using smtp details.

public function mailsend($to,$from,$subject,$message){
        $mail->SetFrom($from, 'Publicfinance.in');
        $mail->Subject    = $subject;
        $mail->AddAddress($to, "");
        if(!$mail->Send()) {
            echo "Mailer Error: " . $mail->ErrorInfo;
        }else {
            echo "Message sent!";

Leave a Reply

Your email address will not be published. Required fields are marked *