My Account

how to generate csv file and send as attachment in cakephp

0 votes
52 views
asked in Web Development by anonymous
how to generate csv file and send as attachment in cakephp

1 Answer

0 votes
answered by Bhartesh (2,620 points)
edited by Bhartesh

To generate csv file you can check this question (Already answered) : 

How to generate CSV file in cake php?

And to send it on attachment this code can help you, pls check :
 
$email = new PHPMailer(); 
$email->From = 'you@example.com'; 
$email->FromName = 'Your Name';
 $email->Subject = 'Message Subject'; 
$email->Body = $bodytext;
 $email->AddAddress( 'destinationaddress@example.com' ); 
$file_to_attach = 'PATH_OF_YOUR_FILE_HERE';
 $email->AddAttachment( $file_to_attach , 'NameOfFile.pdf' ); 
return $email->Send();

Related Questions

+6 votes
2 answers 1,133 views
+5 votes
1 answer 1,123 views
+6 votes
3 answers 6,099 views
+2 votes
1 answer 116 views
+2 votes
3 answers 256 views
+2 votes
1 answer 118 views