lib/classes/Swift/FileSpool.php
public function queueMessage(Swift_Mime_SimpleMessage $message)
    {
        $ser = serialize($message);
        $fileName = $this->path.'/'.$this->getRandomString(10);
        for ($i = 0; $i < $this->retryLimit; ++$i) {
            /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */
            $fp = @fopen($fileName.'.message', 'xb');
            if (false !== $fp) {
                if (false === fwrite($fp, $ser)) {
                    return false;
                }

                return fclose($fp);
            } else {
                /* The file already exists, we try a longer fileName */
                $fileName .= $this->getRandomString(1);
            }
        }

        throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->path));
    }
public function queueMessage(Swift_Mime_SimpleMessage $message)
    {
        $ser = serialize($message);
        $fileName = $this->path.'/'.$this->getRandomString(10);
        for ($i = 0; $i < $this->retryLimit; ++$i) {
            /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */
            $fp = @fopen($fileName.'.message', 'xb');
            if (false !== $fp) {
                if (false === fwrite($fp, $ser)) {
                    return false;
                }

                return fclose($fp);
            } else {
                /* The file already exists, we try a longer fileName */
                $fileName .= $this->getRandomString(1);
            }
        }

        throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->path));
    }
public function queueMessage ( Swift_Mime_SimpleMessage $ message ) { $ ser = serialize ( $ message ) ; $ fileName = $ this -> path . '/' . $ this -> getRandomString ( 10 ) ; for ( $ i = 0 ; $ i < $ this -> retryLimit ; ++ $ i ) { /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */ $ fp = @ fopen ( $ fileName . '.message' , 'xb' ) ; if ( false !== $ fp ) { if ( false === fwrite ( $ fp , $ ser ) ) { return false ; } return fclose ( $ fp ) ; } else { /* The file already exists, we try a longer fileName */ $ fileName .= $ this -> getRandomString ( 1 ) ; } } throw new Swift_IoException ( sprintf ( 'Unable to create a file for enqueuing Message in "%s".' , $ this -> path ) ) ; }
Queues a message.

@param Swift_Mime_SimpleMessage $message The message to store

@throws Swift_IoException

@return bool
Queues a message .