generateId() public method

Generates a valid Message-ID and switches to it.
public generateId ( ) : string
return string
Esempio n. 1
0
 /**
  * Outputs the mail to a text file according to RFC 4155.
  *
  * @param Swift_Mime_Message $message The message to send
  * @param string[] &$failedRecipients To collect failures by-reference, nothing will fail in our debugging case
  * @return int
  * @throws \RuntimeException
  */
 public function send(\Swift_Mime_Message $message, &$failedRecipients = NULL)
 {
     $message->generateId();
     // Create a mbox-like header
     $mboxFrom = $this->getReversePath($message);
     $mboxDate = strftime('%c', $message->getDate());
     $messageStr = sprintf('From %s  %s', $mboxFrom, $mboxDate) . LF;
     // Add the complete mail inclusive headers
     $messageStr .= $message->toString();
     $messageStr .= LF . LF;
     $lockObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Locking\\Locker', $this->debugFile, $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']);
     /** @var \TYPO3\CMS\Core\Locking\Locker $lockObject */
     $lockObject->acquire();
     // Write the mbox file
     $file = @fopen($this->debugFile, 'a');
     if (!$file) {
         $lockObject->release();
         throw new \RuntimeException(sprintf('Could not write to file "%s" when sending an email to debug transport', $this->debugFile), 1291064151);
     }
     @fwrite($file, $messageStr);
     @fclose($file);
     \TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($this->debugFile);
     $lockObject->release();
     // Return every receipient as "delivered"
     $count = count((array) $message->getTo()) + count((array) $message->getCc()) + count((array) $message->getBcc());
     return $count;
 }
Esempio n. 2
0
 /**
  * Outputs the mail to a text file according to RFC 4155.
  *
  * @param \Swift_Mime_Message $message The message to send
  * @param string[] &$failedRecipients To collect failures by-reference, nothing will fail in our debugging case
  * @return int
  * @throws \RuntimeException
  */
 public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
 {
     $message->generateId();
     // Create a mbox-like header
     $mboxFrom = $this->getReversePath($message);
     $mboxDate = strftime('%c', $message->getDate());
     $messageStr = sprintf('From %s  %s', $mboxFrom, $mboxDate) . LF;
     // Add the complete mail inclusive headers
     $messageStr .= $message->toString();
     $messageStr .= LF . LF;
     $lockFactory = GeneralUtility::makeInstance(LockFactory::class);
     $lockObject = $lockFactory->createLocker('mbox');
     $lockObject->acquire();
     // Write the mbox file
     $file = @fopen($this->debugFile, 'a');
     if (!$file) {
         $lockObject->release();
         throw new \RuntimeException(sprintf('Could not write to file "%s" when sending an email to debug transport', $this->debugFile), 1291064151);
     }
     @fwrite($file, $messageStr);
     @fclose($file);
     GeneralUtility::fixPermissions($this->debugFile);
     $lockObject->release();
     // Return every recipient as "delivered"
     $count = count((array) $message->getTo()) + count((array) $message->getCc()) + count((array) $message->getBcc());
     return $count;
 }
Esempio n. 3
0
 /**
  * Outputs the mail to a text file according to RFC 4155.
  *
  * @param \Swift_Mime_Message $message The message to send
  * @param array &$failedRecipients Failed recipients (no failures in this transport)
  * @return integer
  */
 public function send(\Swift_Mime_Message $message, &$failedRecipients = NULL)
 {
     $message->generateId();
     // Create a mbox-like header
     $mboxFrom = $this->getReversePath($message);
     $mboxDate = strftime('%c', $message->getDate());
     $messageString = sprintf('From %s  %s', $mboxFrom, $mboxDate) . chr(10);
     // Add the complete mail inclusive headers
     $messageString .= $message->toString();
     $messageString .= chr(10) . chr(10);
     // Write the mbox file
     file_put_contents($this->mboxPathAndFilename, $messageString, FILE_APPEND | LOCK_EX);
     // Return every receipient as "delivered"
     return count((array) $message->getTo()) + count((array) $message->getCc()) + count((array) $message->getBcc());
 }
 /**
  * Outputs the mail to a text file according to RFC 4155.
  *
  * @param Swift_Mime_Message $message The message to send
  * @param string[] &$failedRecipients To collect failures by-reference, nothing will fail in our debugging case
  * @return int
  * @throws Exception
  */
 public function send(Swift_Mime_Message $message, &$failedRecipients = null)
 {
     $message->generateId();
     // Create a mbox-like header
     $mboxFrom = $this->getReversePath($message);
     $mboxDate = strftime('%c', $message->getDate());
     $messageStr = sprintf('From %s  %s', $mboxFrom, $mboxDate) . LF;
     // Add the complete mail inclusive headers
     $messageStr .= $message->toString();
     $messageStr .= LF . LF;
     // Write the mbox file
     $file = @fopen($this->debugFile, 'a');
     if (!$file) {
         throw new Exception(sprintf('Could not write to file "%s" when sending an email to debug transport', $this->debugFile), 1291064151);
     }
     flock($file, LOCK_EX);
     @fwrite($file, $messageStr);
     flock($file, LOCK_UN);
     @fclose($file);
     t3lib_div::fixPermissions($this->debugFile);
     // Return every receipient as "delivered"
     $count = count((array) $message->getTo()) + count((array) $message->getCc()) + count((array) $message->getBcc());
     return $count;
 }