php - PHPMailer how to add embedded image inside foreach loop
PHPmailer will not let me add an embedded image inside a foreach loop the path is correct but for some reason it is not adding the image i have checked other sorces on here but with no luck the images are embedding fine when out of the loop but it is just when i call them by using variable names eg the way i need to inside a for each loop as the images will be dynamic it will not embed any help appreciated.
The path looks all good but it just will not run in the loop? Please let me know if you need to see any more code i just did not want to include irrelevant code as i know the message is already sending fine it is just this bit that i have a problem with. I have the table working in html that is not being sent via email if that is of any use outputting the images correctly in the foreach loop
<tbody>'.
'<span class="page_speed_630936170">'. $i = 1;' .</span>'.
$total_quantity_count = 0;
$grand_total = 0;
foreach($items_purchased_array as $item){
if (!$mail->addEmbeddedImage(getcwd() . '/' . $item['image'],'product_pic'.$i)) {
echo 'Failed to attach '. getcwd() . '/' . $item['image'],'product_pic'.$i;
}
</tbody>
Answer
Solution:
Here was what i did to fix this