Mail extension

All the details are here:

Hope it’s of use to someone! I use it in at least three applications so far.

All comments welcome

Jonah, the download file is missing in google code…is there another way for us to get it?


Alright, I made a download file. I was hoping people would just get it with subversion

Here it is:

How it works compared to Zend_Mail?

Wouldn’t know, I’ve never used Zend_Mail. Is it good? I’m happy with SwiftMailer though - it’s pretty solid.

EDIT: I added an example to the extension page, even though there are more examples in the phpdoc. I did this because some people don’t care to look at the code unless they see examples first. Here it is:



Well, yes. Zend_Mail is good enough for me. SwiftMailer wrapper looks good. Very good.

This is my controller’s code:


	 * Creates a new model.

	 * If creation is successful, the browser will be redirected to the 'view' page.


	public function actionCreate()


		$model=new Profiles;

		$user = new Users;

		// Uncomment the following line if AJAX validation is needed







			$this->tmpPassword = genRandomString();







			if($model->validate())	{

				if($user->save())	{



					if($model->save())	{

						//email the new password

						$message = new YiiMailMessage;

						$message->setBody('This is test 1 for random password: '.$this->tmpPassword, 'text/html');

						$message->subject = 'System generated password test 1';


						$message->from = Yii::app()->params['adminEmail'];











and in my config/main:

// autoloading model and component classes











         'mail' => array(

 			'class' => 'ext.mail.YiiMail',

 			'transportType' => 'php',

 			'viewPath' => 'application.views.mail',

 			'logging' => true,

 			'dryRun' => false




	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']


		// this is used in contact page



No error was produced,so I expected that I will receive the email. But none.

Kindly point out what I missed.


I am a novice to Yii framework and I was trying to use your extension.

I have a little problem configuring your extension in my framework.

I want to use SMTP transport so I defined the transport type as smtp but how do I define my transport now. If i try to use

'transport'=>Swift_SmtpTransport::newInstance('', 465,'sslv')



php doesnt recognizes Swift_SmtpTransport file.If i try to declare them alter in mycontroller it says YiiMail.transport is readOnly. So where and how should I declare transport and mailer variables

$transport is a protected property of YiiMail class, it can’t be set directly from config. Try this instead:

'transportOptions' => array(

	'host' => '...',

	'port' => '...',

	'encryption' => '..',

	'username' => '...',

	'password' => '..',


I think that Yii Applications should have a Mail component out of the box