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


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, "");
        echo "Mailer Error: " . $mail->ErrorInfo;
        echo "Message sent!";

  • hpm

    Thanks, It works great.

  • Pravin Vanmore

    above code is not working in my case whats the issue ?