header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="file.csv"');
echo "blabla";
$Email = new CakeEmail();
$Email->from(array('no-reply@something.com' => 'Something'));
$Email->to($email);
$Email->subject('Something');
$Email->send($textEmail);
How can I output and give the file to download before sending an email? Is it possible? Or I have to create a temporary file for that myself? It works if I don't send an email.