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

MimeMessage::__construct() throws TypeError with $mode=stream #27

Closed
akamah opened this issue Dec 27, 2022 · 3 comments
Closed

MimeMessage::__construct() throws TypeError with $mode=stream #27

akamah opened this issue Dec 27, 2022 · 3 comments

Comments

@akamah
Copy link

akamah commented Dec 27, 2022

I have read this section of README.md and tried the following code:

<?php
$fp = fopen("tests/testdata/uue.txt", "r");
$msg = new MimeMessage("stream", $fp);
var_dump($msg);

But resulted in the following TypeError:

PHP Fatal error:  Uncaught TypeError: mimemessage::__construct(): supplied argument is not a valid stream resource in /Users/akm/repo/pecl-mail-mailparse/test.php:3
Stack trace:
#0 /Users/akm/repo/pecl-mail-mailparse/test.php(3): mimemessage->__construct()
#1 {main}
  thrown in /Users/akm/repo/pecl-mail-mailparse/test.php on line 3

I confirmed it works correctly when the mode is 'file':

<?php
$msg = new MimeMessage("file", "tests/testdata/uue.txt");
var_dump($msg);

Output:

class mimemessage#1 (2) {
  public $data =>
  array(11) {
    'headers' =>
...

I expect the MimeMessage object can be initialized correctly even if $mode is 'stream'.

Environment

  • mailparse version: 3.1.4
  • PHP Version: 8.1.13
  • Operating System: macOS 12.5.1
@akamah
Copy link
Author

akamah commented Dec 27, 2022

I think we don't need the following line to convert the argument into string but I'm not sure.

convert_to_string_ex(&part->source.zval);

@remicollet
Copy link
Contributor

I think we don't need the following line to convert the argument into string but I'm not sure.

INdeed.

@remicollet
Copy link
Contributor

Please test from git

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

2 participants