Example #1
0
 /**
  * Saves e-mail message to a file
  *
  * @param Message $message
  * @throws Exception\RuntimeException on not writable target directory or
  * on file_put_contents() failure
  */
 public function send(Message $message)
 {
     $options = $this->options;
     $filename = call_user_func($options->getCallback(), $this);
     $file = $options->getPath() . DIRECTORY_SEPARATOR . $filename;
     $email = $message->toString();
     if (false === file_put_contents($file, $email)) {
         throw new Exception\RuntimeException(sprintf('Unable to write mail to file (directory "%s")', $options->getPath()));
     }
     $this->lastFile = $file;
 }
Example #2
0
 /**
  * Prepare body string from message
  *
  * @param  Message $message
  * @return string
  */
 protected function prepareBody(Message $message)
 {
     return $message->getBodyText();
 }
 /**
  * Prepare additional_parameters argument
  *
  * Basically, overrides the MAIL FROM envelope with either the Sender or
  * From address.
  *
  * @param  \Zend\Mail\Message $message
  * @return string
  */
 protected function prepareParameters(Mail\Message $message)
 {
     if ($this->isWindowsOs()) {
         return null;
     }
     $parameters = (string) $this->parameters;
     $sender = $message->getSender();
     if ($sender instanceof AddressInterface) {
         $parameters .= ' -f ' . $sender->getEmail();
         return $parameters;
     }
     $from = $message->getFrom();
     if (count($from)) {
         $from->rewind();
         $sender = $from->current();
         $parameters .= ' -f ' . $sender->getEmail();
         return $parameters;
     }
     return $parameters;
 }