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

Exception while send mail with attached csv file #251

Closed
0l1v3r5 opened this Issue Aug 29, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@0l1v3r5

0l1v3r5 commented Aug 29, 2017

Issue summary

Exception 'TypeError' with message 'fclose() expects parameter 1 to be resource, integer given'

in vendor/league/csv/src/Stream.php (line 131)

System informations

League\Csv - ^9.0
PHP - PHP 7.1.8 (cli) (built: Aug 2 2017 08:32:24) ( NTS )
OS Platform - FEDORA 26

Standalone code, or other way to reproduce the problem

$header = ['first', 'second', 'third'];
$records = [
[1, 2, 3],
['foo', 'bar', 'baz'],
['john', 'doe', 'john.doe@example.com'],
];

//load the CSV document from a string
$csv = Writer::createFromString('');

//insert the header
$csv->insertOne($header);

//insert all the records
$csv->insertAll($records);

// Create the message
$message = (new \Swift_Message())

// Give the message a subject
->setSubject('New')

// Set the From address with an associative array
->setFrom(john2@example.com)

// ->setTo()
->setTo($this->getParameter('recipients'))

// Give it a body
->setBody('new message.');

// Create the attachment with our data
$attachment = (new \Swift_Attachment())
->setFilename('file.csv')
->setContentType('text/csv')
->setBody("$csv") ;

// Attach it to the message
$message->attach($attachment);

$this->get('mailer')->send($message);

Expected result

send mail with attached csv file

Actual result

mail sent but with exception

nyamsprod added a commit that referenced this issue Aug 30, 2017

@nyamsprod nyamsprod self-assigned this Aug 30, 2017

@nyamsprod

This comment has been minimized.

Show comment
Hide comment
@nyamsprod

nyamsprod Aug 30, 2017

Member

This is fixed on the master branch you can clone it and see if you still get the error. If no error is shown I'll close this issue.

Member

nyamsprod commented Aug 30, 2017

This is fixed on the master branch you can clone it and see if you still get the error. If no error is shown I'll close this issue.

nyamsprod added a commit that referenced this issue Aug 30, 2017

@0l1v3r5 0l1v3r5 closed this Aug 30, 2017

@0l1v3r5

This comment has been minimized.

Show comment
Hide comment
@0l1v3r5

0l1v3r5 Aug 30, 2017

everything is ok. Good job. Sorry for closing. I had to let you close it. my bad.

0l1v3r5 commented Aug 30, 2017

everything is ok. Good job. Sorry for closing. I had to let you close it. my bad.

@0l1v3r5 0l1v3r5 reopened this Aug 30, 2017

@0l1v3r5

This comment has been minimized.

Show comment
Hide comment
@0l1v3r5

0l1v3r5 Aug 30, 2017

thank you.

0l1v3r5 commented Aug 30, 2017

thank you.

@nyamsprod

This comment has been minimized.

Show comment
Hide comment
@nyamsprod

nyamsprod Aug 30, 2017

Member

don't worry it was ok for me that you've close it 👍

Member

nyamsprod commented Aug 30, 2017

don't worry it was ok for me that you've close it 👍

@nyamsprod nyamsprod closed this Aug 30, 2017

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