Skip to content

Bug: fwrite(): supplied resource is not a valid stream resource #9647

Description

@dylanfcsr

PHP Version

8.4

CodeIgniter4 Version

4.6.2

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Database

PostgreSQL 9.6

What happened?

I upgraded from version 4.4.0 to 4.6.2 before, I did not have this error when sending email

Steps to Reproduce

// configuration de base des mails
$config['userAgent'] = 'CodeIgniter';
$config['protocol'] = 'smtp';

$config['SMTPTimeout'] = 5;
$config['wordWrap'] = TRUE;
$config['wrapChars'] = 76;
$config['mailType'] = 'html';
$config['charset'] = 'utf-8';
$config['validate'] = FALSE;
$config['priority'] = 3;
$config['CRLF'] = "\r\n";
$config['newline'] = "\r\n";
$config['BCCBatchMode'] = FALSE;
$config['BCCBatchSize'] = 200;

$config['SMTPCrypto'] = '';
$config['SMTPHost'] = '10.0.0.2';
$config['SMTPUser'] = '';
$config['SMTPPass'] = '';
$config['SMTPPort'] = 25;
$email->initialize($config);

$email->clear(true);

foreach ($file  as $key => $value) {
    $email->attach($value);
}

if ($email->send()) {
    $response['success'] = true;
    $response['messages'] = 'Le mail à bien été transmis au client';
} else {
    $response['success'] = false;
    $response['messages'] =  $email->printDebugger();
}

Expected Output

The email was sent, but I get this error every time I send an email that I didn't have before.

Anything else?

{
    "title": "TypeError",
    "type": "TypeError",
    "code": 500,
    "message": "fwrite(): supplied resource is not a valid stream resource",
    "file": "/var/www/html/planning/vendor/codeigniter4/framework/system/Email/Email.php",
    "line": 2084,
    "trace": [
        {
            "file": "/var/www/html/planning/vendor/codeigniter4/framework/system/Email/Email.php",
            "line": 2084,
            "function": "fwrite"
        },
        {
            "file": "/var/www/html/planning/vendor/codeigniter4/framework/system/Email/Email.php",
            "line": 1993,
            "function": "sendData",
            "class": "CodeIgniter\\Email\\Email",
            "type": "->"
        },
        {
            "file": "/var/www/html/planning/vendor/codeigniter4/framework/system/Email/Email.php",
            "line": 2232,
            "function": "sendCommand",
            "class": "CodeIgniter\\Email\\Email",
            "type": "->"
        },
        {
            "function": "__destruct",
            "class": "CodeIgniter\\Email\\Email",
            "type": "->"
        }
    ]
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions