SwiftMailer error Undefined property: Swift_Transport_StreamBuffer::$_sequence SwiftMailer error Undefined property: Swift_Transport_StreamBuffer::$_sequence php php

SwiftMailer error Undefined property: Swift_Transport_StreamBuffer::$_sequence


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.


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;...


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