getSubject() public méthode

Returns the encoded subject of the message
public getSubject ( ) : string
Résultat string
 public function sendMail(Zend_Mail $mail, $body, $headers)
 {
     /**
      * @todo error checking
      */
     mail(join(',', $mail->getRecipients()), $mail->getSubject(), $body, $headers);
 }
Exemple #2
0
 /**
  * Allows caller to have the mail subject dynamically set to contain the
  * entry counts per-priority level.
  *
  * Sets the text for use in the subject, with entry counts per-priority
  * level appended to the end.  Since a Zend_Mail subject can only be set
  * once, this method cannot be used if the Zend_Mail object already has a
  * subject set.
  *
  * @param  string $subject Subject prepend text.
  * @return Zend_Log_Writer_Mail
  * @throws Zend_Log_Exception
  */
 public function setSubjectPrependText($subject)
 {
     if ($this->_mail->getSubject()) {
         throw new Zend_Log_Exception('subject already set on mail; ' . 'cannot set subject prepend text');
     }
     $this->_subjectPrependText = (string) $subject;
     return $this;
 }
 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;
 }
Exemple #4
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);
     }
 }
 /**
  * send Zend_Mail message via smtp
  * 
  * @param  mixed      $accountId
  * @param  Zend_Mail  $mail
  * @param  boolean    $saveInSent
  * @param  Felamimail_Model_Message $originalMessage
  * @return Zend_Mail
  */
 public function sendZendMail($accountId, Zend_Mail $mail, $saveInSent = false, $originalMessage = NULL)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Sending message with subject ' . $mail->getSubject());
     }
     if ($originalMessage !== NULL) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Original Message subject: ' . $originalMessage->subject . ' / Flag to set: ' . var_export($originalMessage->flags, TRUE));
         }
         // this is required for adding the reply/forward flag in _sendMailViaTransport()
         $originalMessage->original_id = $originalMessage;
     }
     // increase execution time (sending message with attachments can take a long time)
     $oldMaxExcecutionTime = Tinebase_Core::setExecutionLifeTime(300);
     // 5 minutes
     // get account
     $account = $accountId instanceof Felamimail_Model_Account ? $accountId : Felamimail_Controller_Account::getInstance()->get($accountId);
     $this->_setMailFrom($mail, $account);
     $this->_setMailHeaders($mail, $account);
     $this->_sendMailViaTransport($mail, $account, $originalMessage, $saveInSent);
     // reset max execution time to old value
     Tinebase_Core::setExecutionLifeTime($oldMaxExcecutionTime);
     return $mail;
 }
Exemple #9
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());
 }
Exemple #10
0
 /**
  * send Zend_Mail message via smtp
  * 
  * @param  mixed      $_accountId
  * @param  Zend_Mail  $_message
  * @param  bool       $_saveInSent
  * @return Zend_Mail
  */
 public function sendZendMail($_accountId, Zend_Mail $_mail, $_saveInSent = false)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Sending message with subject ' . $_mail->getSubject());
     }
     // increase execution time (sending message with attachments can take a long time)
     $oldMaxExcecutionTime = Tinebase_Core::setExecutionLifeTime(300);
     // 5 minutes
     // get account
     $account = $_accountId instanceof Felamimail_Model_Account ? $_accountId : Felamimail_Controller_Account::getInstance()->get($_accountId);
     $this->_setMailFrom($_mail, $account);
     $this->_setMailHeaders($_mail, $account);
     $this->_sendMailViaTransport($_mail, $account, NULL, $_saveInSent);
     // reset max execution time to old value
     Tinebase_Core::setExecutionLifeTime($oldMaxExcecutionTime);
     return $_mail;
 }