Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Core_Mailer

AlexFloppy edited this page Jan 27, 2015 · 3 revisions

Описание

Данный компонент позволяет организовать хранилище шаблонов писем в вашей системе, с возможностью изменения шаблонов с панели администратора.

Настройка

Использование ZendMail

Хранилище DbTable

Пример настройки хранилища шаблонов писем на основе БД

resources:
  frontController:
    mailer:
      storage:
        type: DbTable
        options:
          table: Model_Mail_Table
Транспорт Zend_Mail_Transport_Smtp
resources:
  frontController:
    mailer:
      transport:
        type: ZendMail
        options:
          fromEmail: zfc@nixsolutions.com
          fromName: ZFCore Webmaster
          charset: UTF-8
          transport:
            class: Zend_Mail_Transport_Smtp
            host: stubmail.nixsolutions.com
            port: 2500
Транспорт Zend_Mail_Transport_Sendmail
resources:
  frontController:
    mailer:
      transport:
        type: ZendMail
        options:
          fromEmail: zfc@nixsolutions.com
          fromName: ZFCore Webmaster
          charset: UTF-8
          transport:
            class: Zend_Mail_Transport_Sendmail
            params: 
              - -fzfc@nixsolutions.com
Транспорт Zend_Mail_Transport_File
resources:
  frontController:
    mailer:
      transport:
        type: ZendMail
        options:
          fromEmail: zfc@nixsolutions.com
          fromName: ZFCore Webmaster
          charset: UTF-8
          transport:
            class: Zend_Mail_Transport_File
            path: APPLICATION_PATH/../data/mail

Использование

Приведу пример использования с комментариями:

<?php
// получаем шаблон из хранилища по уникальному идентификатору
$template = Core_Mailer::getTemplate('registration');

// настраиваем адресат
$template->toEmail = $email;
$template->toName  = $login;

// назначаем переменные - будут проведены замены для %host% и %hash% во всех полях
$template->assign('hash', $hashCode);
$template->assign('host', $_SERVER['HTTP_HOST']);

// отправляем сообщение
Core_Mailer::send($template);
?>