14

I'm using SwiftMailer to send email by SMTP. The library is working fine when running in the server with PHP version 5.4. However, after upgrading the server to PHP version 5.5, email was not sent and the server threw the following error:

Undefined property: Swift_Transport_StreamBuffer::$_sequence

How can I resolve this issue? Thanks.

Osh Mansor
  • 1,232
  • 2
  • 20
  • 42
  • Please also say, which version of Swiftmailer that is related to. Also please check, if a bug-report exists and if not create one. Then reference that with your answer. – hakre Sep 26 '14 at 06:55
  • Issue had been reported Aug 2013 - https://github.com/swiftmailer/swiftmailer/issues/361 - So no need to report it. Also no need to provide a patch *if* you use an outdated Swiftmailer library. **Which version is this about?** – hakre Sep 26 '14 at 07:08

3 Answers3

27

In swift-mailer/classes/Swift/ByteStream/AbstractFilterableInputStream.php change

 private $_sequence = 0;

to

 protected $_sequence = 0;

Then the message goes away.

I must use a different version of Swiftmailer than you in the legacy project I got the exact same error notice. My Swift::VERSION is 4.1.1.

hakre
  • 193,403
  • 52
  • 435
  • 836
  • 2
    As you can read in the comments, in newer versions of Swiftmailer the variable is changed in exact the way hakre describes here: https://github.com/swiftmailer/swiftmailer/issues/361 – Daan Jul 15 '15 at 09:42
4

I have resolved the issue by doing the following:

Open lib/classes/Swift/Transport/StreamBuffer.php

Add private $_sequence in the class as shown below:

class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_Transport_IoBuffer
{
    private $_sequence; /** added to fix the undefined property error **/

    /** A primary socket */
    private $_stream;

    /** The input stream */
    private $_in;
...
Osh Mansor
  • 1,232
  • 2
  • 20
  • 42
0

The change has to be done in both these files:

  • swift-mailer/classes/Swift/ByteStream/AbstractFilterableInputStream.php
  • lib/classes/Swift/Transport/StreamBuffer.php

After only changing one I got this:

PHP Fatal error: Access level to Swift_Transport_StreamBuffer::$_sequence must be protected (as in class Swift_ByteStream_AbstractFilterableInputStream) or weaker in /opt/viptel/recorder/lib/classes/Swift/Transport/StreamBuffer.php on line 20

Kjeld Flarup
  • 1,471
  • 10
  • 15