Reputation: 4896
Previously I was attaching a single pdf file like this to the mail function .
Mail::send('emails.questionnairefilled', $data1, function($message) use($htmltosend, $emails){
$message->to($emails)
->from('[email protected]')
->subject(Auth::user()->name.', '.Auth::user()->event.'- Questionnaire completed')
->attachData(
$htmltosend,
Auth::user()->name.'_questionnaire.pdf',
array('mime'=>'application/pdf', 'Content-Disposition'=>'attachment')
);
});
So if I have to attach more files then do I have to use the attachData()
function multiple times or there is some other way .
Thanks
Upvotes: 1
Views: 1575
Reputation: 3635
$path =[];
$path[] = '../path/your/number/one/file';
$path[] = '../path/your/number/two/file';
$data_mail = Mail::send($tmp, array('msg'=>$msg), function($message) use ($path) {
$message->from('[email protected]', $_POST['subj'] );
$message->to($_POST['to'])->subject($_POST['subj'] );
$size = sizeOf($path); //get the count of number of attachments
for($i=0;$i<$size;$i++){
$message->attach($path[i]);
}},true);
Upvotes: 1
Reputation: 605
You can use another email package like Mailgun which helps you to send multiple attachment through his "attach" function
Upvotes: 1