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

Exception while send mail with attached csv file #251

Closed
olivsinz opened this issue Aug 29, 2017 · 4 comments
Closed

Exception while send mail with attached csv file #251

olivsinz opened this issue Aug 29, 2017 · 4 comments

Comments

@olivsinz
Copy link

olivsinz 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', '[email protected]'],
];

//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([email protected])

// ->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
Copy link
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.

nyamsprod added a commit that referenced this issue Aug 30, 2017
@olivsinz
Copy link
Author

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

@olivsinz olivsinz reopened this Aug 30, 2017
@olivsinz
Copy link
Author

thank you.

@nyamsprod
Copy link
Member

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

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

No branches or pull requests

2 participants