Yii framework : Send phpmailer , SMTP

Reference Link : Download extension : smtp-mail

Place This Code in protected/config/main.php file


Place This Code in protected/components/Controller.php file

public function mailsend($to,$from,$from_name,$subject,$message,$cc=array(),$attachment=array())
$mail = Yii::app()->Smtpmail;
$mail->Subject = $subject;
$mail->AddAddress($to, "");

// Add CC
foreach($cc as $email){

// Add Attchments
foreach($attachment as $attach){

if(!$mail->Send()) {
return false; // Fail echo "Mailer Error: " . $mail->ErrorInfo;
}else {
return true; // Success

Call this function from your controller like this



One thought on “Yii framework : Send phpmailer , SMTP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s