You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: