getRecipients() public method

Return list of recipient email addresses
public getRecipients ( ) : array
return array (of strings)
Beispiel #1
0
 public function sendMail(Zend_Mail $mail, $body, $headers)
 {
     /**
      * @todo error checking
      */
     mail(join(',', $mail->getRecipients()), $mail->getSubject(), $body, $headers);
 }
Beispiel #2
0
 public function sendMail(Zend_Mail $mail, $body, $header)
 {
     $this->mail = $mail;
     $this->body = $body;
     $this->header = $header;
     $this->recipients = $mail->getRecipients();
     $this->subject = $mail->getSubject();
     $this->from = $mail->getFrom();
     $this->called = true;
 }
Beispiel #3
0
 public function send($template, array $values = array())
 {
     // create a new mail
     $mail = new Zend_Mail('UTF-8');
     if (isset($values['to'])) {
         if (is_array($values['to'])) {
             foreach ($values['to'] as $address) {
                 $mail->addTo($address);
             }
         } else {
             $mail->addTo($values['to']);
         }
         unset($values['to']);
     } else {
         throw new Exception('to not send in $values');
     }
     // set cc
     if (isset($values['cc'])) {
         if (is_array($values['cc'])) {
             foreach ($values['cc'] as $address) {
                 $mail->addCc($address);
             }
         } else {
             $mail->addCc($values['cc']);
         }
         unset($values['cc']);
     }
     // set bcc
     if (isset($values['bcc'])) {
         if (is_array($values['bcc'])) {
             foreach ($values['bcc'] as $address) {
                 $mail->addBcc($address);
             }
         } else {
             $mail->addBcc($values['bcc']);
         }
         unset($values['bcc']);
     }
     // get the template
     $templateModel = new Core_Model_Templates();
     $data = $templateModel->show($template, $values);
     // set subject and body
     $mail->setSubject($data['subject']);
     $mail->setBodyText($data['body']);
     if (empty(Daiquiri_Config::getInstance()->mail->debug)) {
         $mail->send();
     } else {
         Zend_Debug::dump($mail->getRecipients());
         Zend_Debug::dump($mail->getSubject());
         Zend_Debug::dump($mail->getBodyText());
     }
 }
 /**
  * Send a mail using this transport
  *
  * @return void
  * @throws \Magento\Framework\Exception\MailException
  */
 public function sendMessage()
 {
     try {
         $sendpulseClient = null;
         $recipients = implode(',', $this->_message->getRecipients());
         $parameters = array('from' => $this->_message->getFrom(), 'to' => $recipients, 'subject' => quoted_printable_decode($this->_message->getSubject()), 'text' => quoted_printable_decode($this->_message->getBodyText(true)), 'html' => quoted_printable_decode($this->_message->getBodyHtml(true)));
         // TODO add attachment support
         $attachments = array();
         /*
         $attachments = array(
             'attachment' => array(
                 '/path/to/file.txt',
                 '/path/to/file.txt'
             )
         );
         */
         # Make the call to the client.
         $result = $sendpulseClient->sendMessage($this->_config->getMailgunDomain(), $parameters, $attachments);
     } catch (\Exception $e) {
         throw new \Magento\Framework\Exception\MailException(new \Magento\Framework\Phrase($e->getMessage()), $e);
     }
 }
 public function mailProvider()
 {
     $data = array();
     $mail = new Zend_Mail();
     $mail->setSubject('Some Mail to log');
     $mail->addTo('*****@*****.**');
     $mail->setBodyText('Some Text');
     $mail->setBodyHtml('<div>Some Html</div>');
     $message = 'Subject: ' . $mail->getSubject() . PHP_EOL;
     $message .= 'To: ' . implode(', ', $mail->getRecipients()) . PHP_EOL;
     $message .= 'Text: ' . $mail->getBodyText()->getContent() . PHP_EOL . PHP_EOL;
     $message .= 'Html: ' . $mail->getBodyHtml()->getContent();
     $data[] = array($mail, $message);
     return $data;
 }
 /**
  * Send a mail using this transport
  *
  * @return void
  * @throws \Magento\Framework\Exception\MailException
  */
 public function sendMessage()
 {
     try {
         /** @var Client $client */
         $client = new Client();
         /** @var $mailgunClient Mailgun */
         $mailgunClient = new Mailgun($this->_config->getMailgunKey(), $client);
         /** @var string $recipients comma separated */
         $recipients = implode(',', $this->_message->getRecipients());
         // Assign default parameters
         $parameters = array('from' => $this->_message->getFrom(), 'to' => $recipients, 'subject' => $this->decodeZendQuotedPrintableHeader($this->_message->getSubject()), 'text' => quoted_printable_decode($this->_message->getBodyText(true)), 'html' => quoted_printable_decode($this->_message->getBodyHtml(true)));
         $parameters = $this->assignOptionalParameters($parameters);
         /** @var array $postFiles */
         $postFiles = $this->getPostFiles();
         $domain = $this->_config->getMailgunDomain();
         $result = $mailgunClient->sendMessage($domain, $parameters, $postFiles);
         $this->getMail()->setResult($result);
         $this->getMail()->setSent($this->createSent())->setSentAt($this->createSentAt())->setTransportId($this->createTransportId());
     } catch (\Exception $e) {
         throw new \Magento\Framework\Exception\MailException(new \Magento\Framework\Phrase($e->getMessage()), $e);
     }
 }
Beispiel #7
0
 /**
  * Send a mail using this transport
  *
  * @param  Zend_Mail $mail
  * @access public
  * @return void
  * @throws Zend_Mail_Transport_Exception if mail is empty
  */
 public function send(Zend_Mail $mail)
 {
     $this->_isMultipart = false;
     $this->_mail = $mail;
     $this->_parts = $mail->getParts();
     $mime = $mail->getMime();
     // Build body content
     $this->_buildBody();
     // Determine number of parts and boundary
     $count = count($this->_parts);
     $boundary = null;
     if ($count < 1) {
         /**
          * @see Zend_Mail_Transport_Exception
          */
         // require_once 'Zend/Mail/Transport/Exception.php';
         throw new Zend_Mail_Transport_Exception('Empty mail cannot be sent');
     }
     if ($count > 1) {
         // Multipart message; create new MIME object and boundary
         $mime = new Zend_Mime($this->_mail->getMimeBoundary());
         $boundary = $mime->boundary();
     } elseif ($this->_isMultipart) {
         // multipart/alternative -- grab boundary
         $boundary = $this->_parts[0]->boundary;
     }
     // Determine recipients, and prepare headers
     $this->recipients = implode(',', $mail->getRecipients());
     $this->_prepareHeaders($this->_getHeaders($boundary));
     // Create message body
     // This is done so that the same Zend_Mail object can be used in
     // multiple transports
     $message = new Zend_Mime_Message();
     $message->setParts($this->_parts);
     $message->setMime($mime);
     $this->body = $message->generateMessage($this->EOL);
     // Send to transport!
     $this->_sendMail();
 }
 /**
  * get raw message as string
  * 
  * @param Zend_Mail $mail
  * @param array $_additionalHeaders
  * @return string
  */
 public function getRawMessage(Zend_Mail $mail = NULL, $_additionalHeaders = array())
 {
     if ($mail !== NULL) {
         // this part is from Zend_Mail_Transport_Abstract::send()
         $this->_isMultipart = false;
         $this->_mail = $mail;
         $this->_parts = $mail->getParts();
         $mime = $mail->getMime();
         // Build body content
         $this->_buildBody();
         // Determine number of parts and boundary
         $count = count($this->_parts);
         $boundary = null;
         if ($count < 1) {
             /**
              * @see Zend_Mail_Transport_Exception
              */
             require_once 'Zend/Mail/Transport/Exception.php';
             throw new Zend_Mail_Transport_Exception('Mail is empty');
         }
         if ($count > 1) {
             // Multipart message; create new MIME object and boundary
             $mime = new Zend_Mime($this->_mail->getMimeBoundary());
             $boundary = $mime->boundary();
         } elseif ($this->_isMultipart) {
             // multipart/alternative -- grab boundary
             $boundary = $this->_parts[0]->boundary;
         }
         // Determine recipients, and prepare headers
         $this->recipients = implode(',', $mail->getRecipients());
         $this->_prepareHeaders($this->_getHeaders($boundary));
         // Create message body
         // This is done so that the same Zend_Mail object can be used in
         // multiple transports
         $message = new Zend_Mime_Message();
         $message->setParts($this->_parts);
         $message->setMime($mime);
         $this->body = $message->generateMessage($this->EOL);
     }
     $mailAsString = $this->getHeaders($_additionalHeaders) . $this->EOL . $this->getBody();
     // convert \n to \r\n
     $mailAsString = preg_replace("/(?<!\\r)\\n(?!\\r)/", "\r\n", $mailAsString);
     return $mailAsString;
 }
Beispiel #9
0
 public function sendRaw(Zend_Mail $mail)
 {
     if ($this->_enabled) {
         try {
             $mail->send($this->getTransport());
         } catch (Exception $e) {
             // Silence? Note: Engine_Exception 's are already logged
             if (!$e instanceof Engine_Exception && Zend_Registry::isRegistered('Zend_Log')) {
                 $log = Zend_Registry::get('Zend_Log');
                 $log->log($e, Zend_Log::ERR);
             }
         }
         // Logging in dev mode
         if ('development' == APPLICATION_ENV) {
             $this->getLog()->log(sprintf('[%s] %s <- %s', 'Zend', join(', ', $mail->getRecipients()), $mail->getFrom()), Zend_Log::DEBUG);
         }
         // Track emails
         Engine_Api::_()->getDbtable('statistics', 'core')->increment('core.emails');
     }
     return $this;
 }
Beispiel #10
0
 /**
  * @group ZF-7702
  */
 public function testReplyToIsNoRecipient()
 {
     $mail = new Zend_Mail();
     $mail->setReplyTo('*****@*****.**', 'foobar');
     $this->assertEquals(0, count($mail->getRecipients()));
 }
 private function SEND_SMTP_ZEND()
 {
     try {
         Server::LoadLibrary("ZEND", "Zend_Mail");
         Server::LoadLibrary("ZEND", "Zend_Mail_Transport_Smtp");
         if (empty($this->MailBodyText)) {
             $this->MailBodyText = ">>";
         }
         if ($this->Mailbox->Authentication == "No") {
             $config = array('port' => $this->Mailbox->Port);
         } else {
             $config = array('auth' => 'login', 'username' => $this->Mailbox->Username, 'password' => $this->Mailbox->Password, 'port' => $this->Mailbox->Port);
         }
         if (!empty($this->Mailbox->SSL)) {
             $config['ssl'] = $this->Mailbox->SSL == 1 ? 'SSL' : 'TLS';
         }
         $transport = new Zend_Mail_Transport_Smtp($this->Mailbox->Host, $config);
         $mail = new Zend_Mail('UTF-8');
         $mail->setBodyText($this->MailBodyText);
         if (!empty($this->MailBodyHTML)) {
             $mail->setBodyHtml($this->MailBodyHTML);
         }
         if (empty($this->FakeSender)) {
             $mail->setFrom($this->Mailbox->Email, $this->Mailbox->SenderName);
         } else {
             $mail->setFrom($this->FakeSender, $this->FakeSender);
         }
         if (strpos($this->Receiver, ",") !== false) {
             $emails = explode(",", $this->Receiver);
             $add = false;
             foreach ($emails as $mailrec) {
                 if (!empty($mailrec) && !Is::Null(strpos($mailrec, "@"))) {
                     if (!$add) {
                         $add = true;
                         $mail->addTo($mailrec, $mailrec);
                     } else {
                         $mail->addBcc($mailrec, $mailrec);
                     }
                 }
             }
         } else {
             if (!Is::Null(strpos($this->Receiver, "@"))) {
                 $mail->addTo($this->Receiver, $this->Receiver);
             }
         }
         $mail->setSubject($this->Subject);
         $mail->setReplyTo($this->ReplyTo, $name = null);
         if (count($mail->getRecipients()) > 0) {
             if ($this->Attachments != null) {
                 foreach ($this->Attachments as $resId => $val) {
                     $res = KnowledgeBaseEntry::GetById($resId);
                     $at = $mail->createAttachment(file_get_contents("./uploads/" . $res["value"]));
                     $at->type = 'application/octet-stream';
                     $at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
                     $at->encoding = Zend_Mime::ENCODING_BASE64;
                     $at->filename = $res["title"];
                 }
             }
             $mail->send($transport);
         }
     } catch (Exception $e) {
         if ($this->TestIt) {
             throw $e;
         } else {
             handleError("111", $this->Mailbox->Host . " send mail connection error: " . $e->getMessage(), "functions.global.inc.php", 0);
         }
         return 0;
     }
     return 1;
 }
Beispiel #12
0
 /**
  * Actually sends the email.  Redirects to dev if needed.
  * 
  * @param Zend_Mail $mail
  */
 private function _performSend($mail)
 {
     if (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'staging') {
         try {
             $mail->send();
             $this->_logger->notice('Send Email: email addressed to ' . implode(',', $mail->getRecipients()));
         } catch (Exception $e) {
             $this->_logger->crit('Send Email: Error sending email to ' . implode(',', $mail->getRecipients()));
         }
     } else {
         // development has all emails redirected to the default recipient
         $auth = Zend_Auth::getInstance();
         $mail = $this->_prepareDevEmail($mail);
         // add a dev note to top of email
         $mail->clearRecipients();
         $mail->addTo($this->_config->email->bcc, 'Test User');
         $this->_logger->notice("Dev email redirected to " . $this->_config->email->bcc);
         try {
             $mail->send();
             $this->_logger->notice("Send Email: Dev email has been sent.");
         } catch (Exception $e) {
             $this->_logger->crit('Send Email: Error sending dev email.');
             //$this->_logger->err($e);     // causes an infinite loop since logger sends an email
         }
     }
 }
Beispiel #13
0
 public function format(Zend_Mail $mail)
 {
     return sprintf("Subject: %s\nTo: %s\nText: %s\n\nHtml: %s", $mail->getSubject(), implode(', ', $mail->getRecipients()), $mail->getBodyText()->getContent(), $mail->getBodyHtml()->getContent());
 }
Beispiel #14
0
 /**
  * send an email
  *
  * @param Zend_Mail $mail
  * @param string $body
  * @param string $headers
  */
 public function sendMail(Zend_Mail $mail, $body, $headers)
 {
     $wasConnected = $this->_con !== null;
     // check if the connection is already there
     if (!$wasConnected) {
         $this->connect();
     } else {
         $this->rset();
     }
     // if already connected, reset connection
     try {
         $this->mail_from($mail->getFrom());
         foreach ($mail->getRecipients() as $recipient) {
             $this->rcpt_to($recipient);
         }
         $this->data($headers . "\r\n" . $body);
     } catch (Zend_Mail_Transport_Exception $e) {
         if (!$wasConnected) {
             $this->disconnect();
         }
         // remove connection if we made one
         throw $e;
     }
     if (!$wasConnected) {
         $this->disconnect();
     }
     // remove connection if we made one
 }