Skip to content

Instantly share code, notes, and snippets.

@onre
Created February 6, 2013 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onre/4722939 to your computer and use it in GitHub Desktop.
Save onre/4722939 to your computer and use it in GitHub Desktop.
// if Yii::app()->controller doesn't exist create a dummy
// controller to render the view (needed in the console app)
if(!($controller = Yii::app()->controller))
$controller = new CController('YiiMail');
// renderPartial won't work with CConsoleApplication, so use
// renderInternal - this requires that we use an actual path to the
// view rather than the usual alias
$viewPath = Yii::app()->findLocalizedFile(Yii::getPathOfAlias(Yii::app()->mail->viewPath.'.'.$this->view).'.php');
$body = $controller->renderInternal($viewPath, array_merge($body, array('mail'=>$this)), true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment