コード例 #1
0
ファイル: LoggingTransport.php プロジェクト: neos/swiftmailer
 /**
  * "Send" the given Message. This transport will add it to a stored collection of sent messages
  * for testing purposes and log the message to the system logger.
  *
  * @param \Swift_Mime_Message $message The message to send
  * @param array &$failedRecipients Failed recipients
  * @return integer
  */
 public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
 {
     self::$deliveredMessages[] = $message;
     $this->systemLogger->log('Sent email to ' . $this->buildStringFromEmailAndNameArray($message->getTo()), LOG_DEBUG, array('message' => $message->toString()));
     return count((array) $message->getTo()) + count((array) $message->getCc()) + count((array) $message->getBcc());
 }
コード例 #2
0
 /**
  * Sends the given message.
  *
  * @param Swift_Mime_Message $message
  * @param string[]           $failedRecipients An array of failures by-reference
  *
  * @return int     The number of sent emails
  */
 public function send(Swift_Mime_Message $message, &$failedRecipients = null)
 {
     $hFile = @fopen($this->sLogFile, 'a');
     if ($hFile) {
         $sTxt = "================== " . date('Y-m-d H:i:s') . " ==================\n";
         $sTxt .= $message->toString() . "\n";
         @fwrite($hFile, $sTxt);
         @fclose($hFile);
     }
     return parent::send($message, $failedRecipients);
 }
コード例 #3
0
ファイル: SYiiMail.php プロジェクト: narwold/Small-Potatoes
 /**
  * Save the complete message to the filesystem for testing and debugging
  *
  * @param Swift_Mime_Message $message the email message to log
  * @throws CException if the file system is not writeable
  */
 protected function saveToFile(Swift_Mime_Message $message)
 {
     if (!$this->logDirectory) {
         $this->logDirectory = Yii::app()->getRuntimePath() . DIRECTORY_SEPARATOR . "email";
     }
     if (($logPath = realpath($this->logDirectory)) === false || !is_dir($logPath) || !is_writable($logPath)) {
         mkdir($this->logDirectory, 0777, true);
     }
     $fileName = 'SwiftMailer_' . $_SERVER['REQUEST_TIME'] . '_' . mt_rand() . '.tmp';
     $file = $this->logDirectory . DIRECTORY_SEPARATOR . $fileName;
     if (!is_writable(dirname($file))) {
         throw new CException('Email log directory "' . dirname($file) . '" does not exist or is not writable');
     }
     if (!file_put_contents($file, quoted_printable_decode($message->toString()))) {
         throw new CException('Unable to log mail');
     }
 }