Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MailQueue->process(): message contained attachment cannot be unsearilzed #32

Open
earx opened this issue Feb 21, 2017 · 7 comments
Open

Comments

@earx
Copy link

earx commented Feb 21, 2017

yii mailqueue/process

PHP Notice 'yii\base\ErrorException' with message 'unserialize(): Error at offset 49151 of 49151 bytes'

in /app/vendor/nterms/yii2-mailqueue/models/Queue.php:70

have following code:

        $ret = Yii::$app->mailqueue->compose(
            '@app/views/mail/feedback_mail',
            [
                'appVersion'    => $data->browser->appVersion,
                'userAgent'	    => $data->browser->userAgent,
                'platform'	    => $data->browser->platform,
                'url'	        => $data->url,
                'note'	        => $data->note,
                'imagedata'	    => $data->img,
            ]
        )
        ->setFrom( Yii::$app->params['mail']['mailFromEmail'] )
        ->setTo( Yii::$app->params['mail']['feedbackEmail']  )
        ->setSubject('Site feedback')
        ->queue();

View:

<html>
    <body>
    <img src="<?= $message->embed($imagedata); ?>">
</body>
@nterms
Copy link
Owner

nterms commented Feb 21, 2017

Can't figure out the issue with the details provided. Did you try updating your yii2-mailqueue?

@earx
Copy link
Author

earx commented Feb 21, 2017

HI!
My apologies for unclear issue..
Yes, I've installed latest version - today.

Issue is: when I've put message to queue using code above, message cannot be sent using yii mailqueue/process - error occurred.

@akorinek
Copy link
Contributor

akorinek commented Mar 1, 2017

Same problem here, I've queued a message with a pdf as an attachment. I get unserialize(): Error at offset 49139 of 49151 bytes. In yii2-mailqueue/models/Queue.php:70

@akorinek
Copy link
Contributor

akorinek commented Mar 1, 2017

Some success on this: It seems that the swiftmessage is stored in a TEXT column, which truncates the serialized object. I converted the column to LONGBLOB and now this error is gone. However, now I get a SWIFT_IoException 'Unable to open file for reading[/tmp/MYFILE]' where MYFILE was the location of the original file I attached to this message. Looks like the swiftmailer is still looking for it there for some reason.

@akorinek
Copy link
Contributor

akorinek commented Mar 2, 2017

Found a solution to the attachment problem:
->attachContent(file_get_contents($this->attachment),['fileName=>$this->filename])
works.

@yeluolei
Copy link

yeluolei commented Sep 7, 2017

same problem here if use $message-> embed()

@marcogermani87
Copy link
Contributor

Fixed with pull request #37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants