<?php
return array(
'viewPath' => 'application.views.mail',
'layoutPath' => 'application.views.layouts',
'baseDirPath' => 'webroot.images.mail',
'layout' => 'mail',
'CharSet' => 'UTF-8',
'AltBody' => Yii::t('YiiMailer','Новое сообщение с сайта'),
'Mailer' => 'smtp',
'Host' => 'smtp.yandex.ru',
'Port' => 465,
'SMTPSecure' => 'ssl',
'SMTPAuth' => true,
'Username' => 'centergorizont@yandex.ru',
'Password' => '123',
'language' => array(
'authenticate' => Yii::t('YiiMailer','SMTP Error: Could not authenticate.'),
'connect_host' => Yii::t('YiiMailer','SMTP Error: Could not connect to SMTP host.'),
'data_not_accepted' => Yii::t('YiiMailer','SMTP Error: Data not accepted.'),
'empty_message' => Yii::t('YiiMailer','Message body empty'),
'encoding' => Yii::t('YiiMailer','Unknown encoding: '),
'execute' => Yii::t('YiiMailer','Could not execute: '),
'file_access' => Yii::t('YiiMailer','Could not access file: '),
'file_open' => Yii::t('YiiMailer','File Error: Could not open file: '),
'from_failed' => Yii::t('YiiMailer','The following From address failed: '),
'instantiate' => Yii::t('YiiMailer','Could not instantiate mail function.'),
'invalid_address' => Yii::t('YiiMailer','Invalid address'),
'mailer_not_supported' => Yii::t('YiiMailer',' mailer is not supported.'),
'provide_address' => Yii::t('YiiMailer','You must provide at least one recipient email address.'),
'recipients_failed' => Yii::t('YiiMailer','SMTP Error: The following recipients failed: '),
'signing' => Yii::t('YiiMailer','Signing Error: '),
'smtp_connect_failed' => Yii::t('YiiMailer','SMTP Connect() failed.'),
'smtp_error' => Yii::t('YiiMailer','SMTP server error: '),
'variable_set' => Yii::t('YiiMailer','Cannot set or reset variable: ')
),
);
public function renderForm1()
{
$model = new Form;
// uncomment the following code to enable ajax-based validation
if(isset($_POST['ajax']) && $_POST['ajax']==='form1')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
if(isset($_POST['Form']))
{
$model->attributes=$_POST['Form'];
if($model->save())
{
$msg = new YiiMailer('form1', array('model' => $model));
$msg->render();
$msg->Subject = 'Новое сообщение через форму (Заказать звонок)';
$msg->AddAddress(Yii::app()->params['adminEmail']);
$msg->setFrom('centergorizont@yandex.ru', Yii::app()->params['title']);
if ($msg->Send()) {
$msg->ClearAddresses();
Yii::app()->user->setFlash('success','Ваше сообщение отправлено.');
Yii::app()->controller->redirect(CHtml::normalizeUrl(array('')+$_GET));
} else {
Yii::app()->user->setFlash('error','Проблема: '.$msg->ErrorInfo);
Yii::app()->controller->redirect(CHtml::normalizeUrl(array('')+$_GET));
}
}
}
$this->render('/form/form1',array('model'=>$model));
}