setOptions($options); } /** * Sets options * * @param FileOptions $options */ public function setOptions(FileOptions $options) { $this->options = $options; } /** * 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; } /** * Get the name of the last file written to * * @return string */ public function getLastFile() { return $this->lastFile; } }