I want to send multiple attachments in a single email. I get file paths from my download directory and store them in an array and than using for each loop attach them to mail->addattachment($filepath), but it always selects the last attachment.I havent added my foreach code for getting file names from DB.
For logs if i do print_r($filePaths); it gives me this output
Array ( [0] => /home/ifixandm/public_html/finalUpGrade/download/resumes/03-02-2016_amir_ETicket-EmmiratsView.pdf )
Array ( [0] => /home/ifixandm/public_html/finalUpGrade/download/resumes/04-02-2016_Florida-Mall_Ammar-ul-hassan.pdf )
Here is my code.
$oresumeCtr = 0;
$filePaths = array();
$filePaths[$oresumeCtr] = DIR_DOWNLOAD ."/resumes/" . $upload_resume; // upload resume is name of resume
foreach($filePaths as $filePath) {
if (isset($filePath) && file_exists($filePath))
{
$mail->addAttachment($filePath);
$this->log->write('resume path in side loop ' .$filePath);
}
}
$mail->send();
I want to send these files as attachments in a single email.