SwiftMailer error Undefined property: Swift_Transport_StreamBuffer::$_sequence
Asked Answered
I

3

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.

Interlaminate answered 24/9, 2014 at 15:34 Comment(2)
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.Encephalography
Issue had been reported Aug 2013 - 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?Encephalography
E
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.

Encephalography answered 26/9, 2014 at 7:13 Comment(1)
As you can read in the comments, in newer versions of Swiftmailer the variable is changed in exact the way hakre describes here: github.com/swiftmailer/swiftmailer/issues/361Longitude
I
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;
...
Interlaminate answered 24/9, 2014 at 15:34 Comment(0)
S
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

Salba answered 16/2, 2016 at 7:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.