本文整理汇总了PHP中YiiMailMessage::setTo方法的典型用法代码示例。如果您正苦于以下问题:PHP YiiMailMessage::setTo方法的具体用法?PHP YiiMailMessage::setTo怎么用?PHP YiiMailMessage::setTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YiiMailMessage
的用法示例。
在下文中一共展示了YiiMailMessage::setTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionRemind
public function actionRemind()
{
if (!Yii::app()->user->isGuest) {
$this->redirect('/cabinet/');
}
$user = new User('pass');
$user = User::model()->find('email=:email', array(':email' => $_POST['User']['email']));
$this->performAjaxValidation($user);
if (isset($_POST['User'])) {
$chars = "123456789abcdefghijklmnopqrstuvwxyz";
$num_chars = strlen($chars);
$char = $chars[rand(0, $num_chars - 1)];
for ($i = 1; $i < 6; $i++) {
$char .= $chars[rand(0, $num_chars - 1)];
}
$user->password = $char;
if ($user->save()) {
$text = "На ваш E-mail был отправлен запрос восстановления пароля:<br /><br /><b>Ваш новый пароль:</b> " . $char . "<br /><br />Администрация Комплекс Бар.";
$message = new YiiMailMessage();
$message->setTo(array($user->email => $user->name . ' ' . $user->lastname));
$message->setFrom(array('noreply@complexbar.ru' => 'Комплекс Бар'));
$message->setSubject('Новый пароля для сайта Complexbar.ru');
$message->setBody($text, 'text/html', 'utf8');
Yii::app()->mail->send($message);
$this->redirect('/auth/?remind');
} else {
exit(var_dump($user->getErrors()));
}
}
$data = array();
$this->render('/users/auth', $data);
}
示例2: sendMail
public static function sendMail($params = array())
{
/** @var $message YiiMailMessage */
$message = new YiiMailMessage();
/*
$base_path = Yii::getPathOfAlias('application.views.mail.images');
$files = CFileHelper::findFiles($base_path);
$imgs = array();
foreach ($files as $file) {
$imgs[basename($file)] = $message->embed(Swift_Image::fromPath($file));
}
if(isset($params['params']['attachedFilePath'], $params['params']['attachedFileName'])) {
$message->attach(Swift_Attachment::fromPath($params['params']['attachedFilePath'])->setFilename($params['params']['attachedFileName']));
}
$params['params']['imgs'] = $imgs;
*/
$message->view = $params['view'];
$message->subject = $params['subject'];
$message->setTo($params['to']);
if (isset($params['cc'])) {
$message->setCc($params['cc']);
}
if (isset($params['bcc'])) {
$message->setBcc($params['bcc']);
}
$message->setBody($params['params'], 'text/html');
$message->addPart(self::getPlainTextVersion($message, $params['params']), 'text/plain');
$message->attachSigner(self::getSigner());
$message->from = Yii::app()->params['mail_sender'];
return Yii::app()->mail->send($message);
}
示例3: sendSenderNotification
/**
* Send notification for user, that has sent message for administration
* @return mixed
*/
public function sendSenderNotification()
{
$this->checkNotificationCondition();
Yii::import('application.extensions.yii-mail.YiiMailMessage');
$senderNotification = new YiiMailMessage();
$senderNotification->setSubject($this->notificationSubject);
$senderNotification->view = $this->notificationViewFile;
$senderNotification->setBody($this->notificationParams, 'text/html');
$senderNotification->setTo($this->notificationReceiver);
$senderNotification->from = $this->notificationSender;
return Yii::app()->mail->send($senderNotification);
}
示例4: sendEmail
public function sendEmail()
{
$this->checkEmailConditions();
Yii::import('application.extensions.yii-mail.YiiMailMessage');
$message = new YiiMailMessage();
$message->setSubject($this->emailSubject);
$message->view = $this->emailViewFile;
$message->setBody($this->emailParams, 'text/html');
$message->setTo($this->receiverEmail);
$message->from = $this->senderEmail;
return Yii::app()->mail->send($message);
}
示例5: actionRubric
public function actionRubric($id = null)
{
if ($_POST['Form']) {
$model = new Form('new');
$this->performAjaxValidation($model);
$model->attributes = $_POST['Form'];
$model->date = time();
if ($_FILES['file']['tmp_name']) {
$file = CUploadedFile::getInstanceByName('file');
$model->file = $file->getName();
}
if ($model->save()) {
$text = 'Имя: ' . $model->name;
$text .= '<br />Фамилия: ' . $model->lastname;
$text .= '<br />E-mail: ' . $model->email;
$text .= '<br />Телефон: ' . $model->tel;
if ($model->arts) {
$text .= '<br />Артикулы под нанесение: ' . $model->arts;
}
if ($model->delivered) {
$text .= '<br />Желаемая дата заказа: ' . $model->delivered;
}
$text .= '<br />Кол-во цветов: ' . $model->color;
$text .= '<br />Тираж: ' . $model->tirazh;
$text .= '<br />Размеры: ' . $model->width . ' x ' . $model->height;
$text .= '<br />Драг.металы:';
$text .= '<br />Золото - ' . ($model->gold ? 'Да' : 'Нет');
$text .= '<br />Платина - ' . ($model->platina ? 'Да' : 'Нет');
if ($model->text) {
$text .= '<br />Примечание: ' . $model->text;
}
$message = new YiiMailMessage();
$message->setTo(array($this->getConfig('email3') => 'Комплекс Бар'));
$message->setFrom(array($model->email => $model->name . ' ' . $model->lastname));
$message->setSubject('Заказ на нанесение');
$message->setBody($text, 'text/html', 'utf8');
if ($_FILES['file']['tmp_name']) {
$fileNewPath = $_SERVER['DOCUMENT_ROOT'] . '/userdata/nanesenie/' . $file->getName();
$file->saveAs($fileNewPath);
$message->attach(Swift_Attachment::fromPath($fileNewPath));
}
Yii::app()->mail->send($message);
Yii::app()->user->setFlash('message', 'Спасибо за заказ. Наш менеджер свяжется с вами в ближайшее время.');
} else {
$this->render('rubric', $data);
}
$this->refresh();
}
$rubric = Rubrics::model()->findByPk($id);
$data = array('rubric' => $rubric);
$this->render('rubric', $data);
}
示例6: actionMailTes
public function actionMailTes()
{
$message = new YiiMailMessage();
$message->setBody('tes', 'text/html');
$message->setTo('neo_gazebo@yahoo.co.id');
$message->setSubject('tes');
$message->setFrom('admin@dcourier.com');
$html2pdf = Yii::app()->ePdf->HTML2PDF();
$html2pdf->WriteHTML('<p>hehehehe</p>');
$html2pdf->Output(dirname(Yii::app()->basePath) . '/pdf/tes.pdf', EYiiPdf::OUTPUT_TO_FILE);
$message->attach(Swift_Attachment::frompath(dirname(Yii::app()->basePath) . '/pdf/tes.pdf'));
Yii::app()->mail->send($message);
CVarDumper::dump(YiiMail::log($message), 10, true);
}
示例7: sendEmail
public function sendEmail()
{
$this->checkEmailConditions();
Yii::import('application.extensions.yii-mail.YiiMailMessage');
$message = new YiiMailMessage();
$message->setSubject($this->subject);
$message->view = 'mass-delivery';
$message->setBody(array('text' => $this->text), 'text/html');
$message->from = Yii::app()->params['emails']['defaultSender'];
if (is_array($this->receiverEmail)) {
foreach ($this->receiverEmail as $email) {
$message->setTo($email);
Yii::app()->mail->send($message);
}
}
return TRUE;
}
示例8: recoverPassword
public function recoverPassword()
{
$u = User::model()->findByAttributes(array('username' => $this->username));
$newPassword = substr(md5(uniqid()), 0, 6);
$u->password = $newPassword;
$u->save();
$body = "Hello " . $u->first_name . ' ' . $u->last_name . ",\n\nYour login details are:\n\n";
$body .= "Username: " . $u->username . "\n";
$body .= "Password: " . $newPassword . "\n";
$body .= "\n\nPromocast Team";
$message = new YiiMailMessage();
$message->setTo(array($u->email => $u->first_name . ' ' . $u->last_name));
$message->setFrom(array('promocast1@gmail.com' => 'Promocast'));
$message->setSubject('Your password');
$message->setBody($body);
$numsent = Yii::app()->mail->send($message);
return true;
}
示例9: save
public function save()
{
/** @var $user User */
$user = User::model()->findByAttributes(array('email' => $this->email));
if ($user) {
$newPassword = substr(md5(rand(1, 100)), 0, 8);
$user->changePassword($newPassword);
$user->save();
Yii::import('application.extensions.yii-mail.YiiMailMessage');
$message = new YiiMailMessage();
$message->setSubject('Відновлення паролю на сайті РЕЗИДЕНТ');
$message->view = 'restore-password';
$message->setBody(array('name' => $user->getFirstName(), 'password' => $newPassword), 'text/html');
$message->setTo($this->email);
$message->from = Yii::app()->params['emails']['defaultSender'];
Yii::app()->mail->send($message);
}
}
示例10: actionComment
public function actionComment()
{
if (!isset($_GET['id'])) {
throw new CHttpException(500, "Ломаешь?");
}
/**
* @var $model SupportTickets
*/
$model = SupportTickets::model()->findByPk($_GET['id']);
if (!$model) {
throw new CHttpException(404, "Не найдено");
}
if (Yii::app()->request->isPostRequest) {
if (isset($_POST['content']) && isset($_POST['toClose'])) {
if ($_POST['toClose'] == 1) {
$model->status = 2;
} else {
$model->status = 1;
}
$model->save();
$m2 = new SupportTicketsComments();
$m2->ticketId = $model->id;
$m2->userId = Yii::app()->user->id;
$m2->datePosted = time();
$m2->isAnswer = 1;
$m2->content = $_POST['content'];
$m2->save();
Yii::import('ext.yii-mail.*');
$message = new YiiMailMessage();
$message->view = 'supportNewReply';
$message->setSubject('Тикет #' . $model->id . " - Новый ответ");
$message->setBody(array('model' => $model), 'text/html');
$message->setTo($model->user->email);
$message->from = array(Yii::app()->params['adminEmail'] => 'Crystal Reality Games');
Yii::app()->mail->send($message);
$this->redirect($this->createUrl("index"));
} else {
$this->redirect($this->createUrl("view", ["id" => $model->id]));
}
}
}
示例11: mail
/**
*
* Generic Mail sender method send the generic perfony html mail
* @param array $params
* contains any param passed on to the generic view file
*
* basePath : absolute server path
* imgPath : absolute path to images folder
* subject : ovious
* email : message mail will be send to
* sectionTitle : message Section tilte
* title : message title
* genericText : information text at the top
* view : defaults to 'contact' but could be different
* body : is the main body of the message
* link : appended to the message for direct access to the subject
* placeholders : key/value array to use to find/replace in body
*
* @param string $view : name of the view to be used a base
*/
public static function mail($params)
{
$k_path_url = (isset($_SERVER['HTTPS']) and !empty($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) != 'off') ? 'https://' : 'http://';
$params['basePath'] = $k_path_url . $_SERVER['SERVER_NAME'] . substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], "/") + 1);
$params['imgPath'] = $params['basePath'] . 'images/email';
$yiimail = new YiiMailMessage();
if (!isset($params['subject'])) {
$params['subject'] = Yii::t('mail', 'subject' . $params['key']);
}
$yiimail->setSubject($params['subject']);
$yiimail->setTo(array($params['email']));
$yiimail->setFrom(array(Yii::app()->params['adminEmail']));
if (!isset($params['sectionTitle'])) {
$params['sectionTitle'] = Yii::t('mail', 'sectionTitle' . $params['key']);
}
if (!isset($params['title'])) {
$params['title'] = Yii::t('mail', 'title' . $params['key']);
}
if (!isset($params['genericText'])) {
$params['genericText'] = Yii::t('mail', 'genericText' . $params['key']);
}
$yiimail->view = isset($params['view']) ? $params['view'] : 'contact';
if (!isset($params['body'])) {
$params['body'] = Yii::t('mail', 'body' . $params['key']);
}
if (isset($params['link'])) {
$params['body'] .= "<br/><a href='" . Yii::app()->createAbsoluteUrl("/" . $params['link']) . "'>" . Yii::t(PTranslate::CAT_MAILS, 'Direct Link to access') . "</a>";
}
if (isset($params['placeholders'])) {
foreach ($params['placeholders'] as $key => $val) {
//throw new CHttpException('pouet avant : '.$params['placeholders'].' après : '.str_replace($key, $val, $params['placeholders']));
$params['body'] = str_replace($key, $val, $params['body']);
}
}
$yiimail->setBody($params, 'text/html');
if (Yii::app()->params['sendMails']) {
Yii::app()->mail->send($yiimail);
}
}
示例12: registerUser
protected function registerUser()
{
$model = new User();
$model->first_name = $this->name;
$model->password = $this->password;
$model->email = $this->email;
$model->sex = $this->sex;
$model->role = WebUser::ROLE_USER;
if ($model->save(FALSE)) {
Yii::import('application.extensions.yii-mail.YiiMailMessage');
$message = new YiiMailMessage();
$message->setSubject('Вітаємо на сайті РЕЗИДЕНТ');
$message->view = 'registration-notification';
$message->setBody(array('name' => $this->name, 'password' => $this->password), 'text/html');
$message->setTo($this->email);
$message->from = Yii::app()->params['emails']['defaultSender'];
Yii::app()->mail->send($message);
$this->_userModel = $model;
return TRUE;
} else {
return FALSE;
}
}
示例13: sendEmail
public function sendEmail($emails, $subject, $message)
{
if ($this->getHost() == null) {
return;
}
/**
* @var $mailer YiiMail
*/
$mailer = Yii::createComponent(array('class' => 'YiiMail', 'transportType' => $this->getMailMethod(), 'transportOptions' => array('host' => $this->getHost()), 'logging' => false));
$mailerTransport = $mailer->getTransport();
if ($this->getAuthUser() !== null) {
//нужна авторизация на сервере
$mailerTransport->setUsername(trim($this->getAuthUser()))->setPassword(trim($this->getAuthPassword()));
} else {
$mailerTransport->setUsername(null)->setPassword(null);
}
$mailMessage = new YiiMailMessage();
$mailMessage->setBody($message, 'text/plain', 'utf-8');
$mailMessage->setFrom($this->getSentFrom());
$mailMessage->setSubject($subject);
$mailMessage->setTo($emails);
$errorMessage = false;
try {
if (!$mailer->send($mailMessage, $failures)) {
$errorMessage = sprintf("Ошибка при отправке почты:\n %s", print_r($failures, true));
}
} catch (Exception $e) {
$errorMessage = $e->getMessage();
}
if ($errorMessage) {
$this->log($errorMessage);
}
}
示例14: send
public function send(array $events)
{
$eventsCount = count($events);
if ($eventsCount == 0) {
return;
}
$mailer = Yii::app()->mailer;
$mailer->init();
for ($i = 0; $i < $eventsCount; $i++) {
$curEvent = $events[$i];
$mailAccount = $curEvent->eventType->mailAccount;
$mailerTransport = $mailer->getTransport()->setHost($mailAccount->host);
if ($mailAccount->getIsNeedAuthorize()) {
//нужна авторизация на сервере
$mailerTransport->setUsername($mailAccount->user_name)->setPassword($mailAccount->user_password);
} else {
$mailerTransport->setUsername(null)->setPassword(null);
}
$eventsProcess = $curEvent->getEventsProcess();
$eventsProcessCount = count($eventsProcess);
for ($k = 0; $k < $eventsProcessCount; $k++) {
$curEventProcess = $eventsProcess[$k];
$mailMessage = new YiiMailMessage();
$mailMessage->setTo($curEventProcess->email);
$mailMessage->setSubject($curEvent->subject);
$messageContent = '';
if ($curEvent->event_message === null) {
$ncEvent = new NotifierComponentEvent($this, $curEvent, $curEventProcess, $mailMessage);
$this->onEmptyMessage(new NotifierComponentEvent($this, $curEvent, $curEventProcess, $mailMessage));
if ($mailMessage->getBody() == null && empty($ncEvent->params['messageContent'])) {
$curEventProcess->saveAsSent();
continue;
} elseif (!empty($ncEvent->params['messageContent'])) {
$messageContent = $ncEvent->params['messageContent'];
}
} else {
$messageContent = $curEvent->event_message;
}
if ($mailMessage->getFrom() == null) {
//если не указан отправитель, то берем из настроек аккаунта
if (!empty($mailAccount->from_name)) {
$mailMessage->setFrom(array($mailAccount->email_from => $mailAccount->from_name));
} else {
$mailMessage->setFrom($mailAccount->email_from);
}
}
//если тема не указана, то в качестве темы устанавливаем название типа события
if ($mailMessage->getSubject() == null) {
$mailMessage->setSubject($curEvent->eventType->name);
}
//Если есть что прикреплять
if (!empty($messageContent)) {
$eventFormat = $curEventProcess->eventSubscriber->eventFormat;
switch ($eventFormat->place) {
case NotifierEventFormat::PLACE_TEXT:
$mailMessage->setBody($messageContent, $eventFormat->name == NotifierEventFormat::TYPE_HTML ? 'text/html' : 'text/plain');
break;
case NotifierEventFormat::PLACE_ATTACHMENT:
$fileName = $eventFormat->file_name;
if ($curEventProcess->eventSubscriber->getIsArchiveAttachment()) {
//TODO Архивируем вложение
}
//TODO Добавляем файл в аттач
break;
}
}
if (!$this->onBeforeSend(new NotifierComponentEvent($this, $curEvent, $curEventProcess, $mailMessage))) {
continue;
}
$errorMessage = false;
try {
if ($mailer->send($mailMessage, $failures)) {
$curEventProcess->saveAsSent();
} else {
$errorMessage = sprintf("Ошибка при отправке почты:\n %s", print_r($failures, true));
}
} catch (Exception $e) {
$errorMessage = $e->getMessage();
}
if ($errorMessage) {
Yii::log($errorMessage, CLogger::LEVEL_ERROR, 'mail.notifier.send');
}
}
// endfor $eventProcess
}
// endfor $events
}
示例15: SendMail
public function SendMail($mail = array())
{
$mailer = new YiiMail();
$mailer->transportType = 'smtp';
$mailer->transportOptions = array('host' => Config::model()->getValueByKey('host_sendmail'), 'username' => Config::model()->getValueByKey('username_sendmail'), 'password' => Config::model()->getValueByKey('password_sendmail'), 'port' => Config::model()->getValueByKey('port_sendmail'), 'encryption' => Config::model()->getValueByKey('encryption_sendmail'));
$message = new YiiMailMessage();
$message->setFrom(array(Config::model()->getValueByKey('username_sendmail') => Config::model()->getValueByKey('displayname_sendmail')));
$message->setTo(array($mail['mailto']));
$message->setReplyTo(array($mail['replyto']));
$message->setSubject($mail['subject']);
$message->setBody($mail['body'], 'text/html');
$mailer->send($message);
}