32 require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.
'phpmailer'.DIRECTORY_SEPARATOR.
'class.phpmailer.php');
54 protected $pathViews =
'application.views.email';
62 protected $pathLayouts =
'application.views.email.layouts';
103 if (!is_string($value) && !preg_match(
"/[a-z0-9\.]/i"))
104 throw new CException(Yii::t(
'EMailer',
'pathLayouts must be a Yii alias path'));
105 $this->pathLayouts = $value;
115 return $this->pathLayouts;
125 if (!is_string($value) && !preg_match(
"/[a-z0-9\.]/i"))
126 throw new CException(Yii::t(
'EMailer',
'pathViews must be a Yii alias path'));
127 $this->pathViews = $value;
137 return $this->pathViews;
153 if (is_object($this->_myMailer) && get_class($this->_myMailer)===
'PHPMailer')
return call_user_func_array(array($this->_myMailer, $method), $params);
154 else throw new CException(Yii::t(
'EMailer',
'Can not call a method of a non existent object'));
163 public function __set($name, $value)
165 if (is_object($this->_myMailer) && get_class($this->_myMailer)===
'PHPMailer') $this->_myMailer->$name = $value;
166 else throw new CException(Yii::t(
'EMailer',
'Can not set a property of a non existent object'));
177 if (is_object($this->_myMailer) && get_class($this->_myMailer)===
'PHPMailer')
return $this->_myMailer->$name;
178 else throw new CException(Yii::t(
'EMailer',
'Can not access a property of a non existent object'));
209 public function getView($view, $vars = array(), $layout = null)
211 $body = Yii::app()->controller->renderPartial($this->pathViews.
'.'.$view, array_merge($vars, array(
'content'=>$this->_myMailer)),
true);
212 if ($layout === null) {
213 $this->_myMailer->Body = $body;
216 $this->_myMailer->Body = Yii::app()->controller->renderPartial($this->pathLayouts.
'.'.$layout, array(
'content'=>$body),
true);