public function restPostNewsletterSend()
 {
     $request = $this->getRequest();
     $postData = $request->getPost();
     $form = new \Core\Form\NewsletterForm();
     $form->bind($postData);
     if ($form->isValid()) {
         $item = $form->getData();
         $file = array();
         if ($form->getFileTransfer()->isUploaded()) {
             $form->getFileTransfer()->receive();
             $files = $form->getFileTransfer()->getFileInfo();
             $file = $files['attachment'];
         }
         $mail = new \Core\Mail();
         $message = $mail->getMessage();
         $emails = explode(',', $item['bcc']);
         foreach ($emails as $email) {
             $message->addBcc($email);
         }
         $message->setSubject($item['subject'])->setBody($item['content']);
         if ($file) {
             $message->addAttachment($file['tmp_name']);
         }
         $mail->send();
         return $this->redirect()->toUrl('/admin/core/newsletter');
     } else {
     }
 }
Beispiel #2
0
 public function sendInvite($params = array())
 {
     $emails = $params['emails'];
     $template = $params['template'];
     $templatePath = $params['templatePath'];
     if (!$emails || !$template || !$templatePath) {
         return array();
     }
     $userModel = Api::_()->getModel('User\\Model\\User');
     $mine = $this->getUser();
     $this->user = $mine = $userModel->getUser($mine['id']);
     if (!$mine) {
         return false;
     }
     $subject = isset($params['subject']) ? $params['subject'] : $this->getSubject();
     $mail = new Mail();
     $message = $mail->getMessage();
     $message->addFrom($mine['email'], $mine['userName']);
     foreach ($emails as $email) {
         $message->addBcc($email);
     }
     $message->setSubject($subject)->setData(array('user' => $this->user, 'url' => $this->getRegUrl()))->setTemplatePath($templatePath)->setTemplate($template);
     return $mail->send($message);
 }
Beispiel #3
0
<?php

require_once './autoloader.php';
$appGlobelConfig = (include EVA_CONFIG_PATH . DIRECTORY_SEPARATOR . 'application.config.php');
$appLocalConfig = EVA_CONFIG_PATH . DIRECTORY_SEPARATOR . 'application.local.config.php';
if (file_exists($appLocalConfig)) {
    $appLocalConfig = (include $appLocalConfig);
    $appGlobelConfig = array_merge($appGlobelConfig, $appLocalConfig);
}
Zend\Mvc\Application::init($appGlobelConfig);
use Core\Mail;
use Zend\Mail\Message;
use Zend\Mail\Transport;
use Zend\Di\Di;
use Zend\Di\Config as DiConfig;
use Zend\Mime\Message as MimeMessage;
use Zend\Mime\Part;
$mail = new Mail();
$message = $mail->getMessage();
$message->setSubject('Eva Mail Subject')->setData(array('user' => 'AlloVince'))->setTemplatePath(__DIR__)->setTemplate('mail/template')->addAttachment('loading.jpg');
$mail->send($message);