CodeIgniter Forums
Image Embedded Email Body - Code Igniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Image Embedded Email Body - Code Igniter (/showthread.php?tid=71385)



Image Embedded Email Body - Code Igniter - vitor1415 - 08-08-2018

I'm having difficulty attaching an image to the body of the email using a standard library of the igniter code.
I already did this:
Code:
$cid = $this->email->attach('media/teste.jpg','inline');
$data['cid']= $cid;
$emailbody = $this->load>view('test/template.php',$data,true);
$this->email->message($emailbody);

view:
Code:
<img src='cid:<?= $cid?>' alt="photo1" height="42" width="42" />'

In case the attachment happens, but in the view the image in the body does not appear.
Can anyone help?


RE: Image Embedded Email Body - Code Igniter - InsiteFX - 08-09-2018

For emails you need the full path to the image file.

(http:// or https://).


RE: Image Embedded Email Body - Code Igniter - Susan Burling - 08-09-2018

I think it is very much similar with your query follow this https://stackoverflow.com/questions/31846167/how-to-display-an-image-in-email-in-codeigniter


RE: Image Embedded Email Body - Code Igniter - vitor1415 - 08-09-2018

Thank you all for your help.

I was able to sort through the documentation.

https://www.codeigniter.com/user_guide/libraries/email.html

$filename = '/img/photo1.jpg';
$this->email->attach($filename);
foreach ($list as $address)
{
       $this->email->to($address);
       $cid = $this->email->attachment_cid($filename);
       $this->email->message('<img src="cid:'. $cid .'" alt="photo1" />');
       $this->email->send();
}



RE: Image Embedded Email Body - Code Igniter - Meena Sutar - 08-16-2018

(08-09-2018, 10:54 AM)vitor1415 Wrote: Thank you all for your help.

I was able to sort through the documentation.

https://www.codeigniter.com/user_guide/libraries/email.html

$filename = '/img/photo1.jpg';
$this->email->attach($filename);
foreach ($list as $address)
{
       $this->email->to($address);
       $cid = $this->email->attachment_cid($filename);
       $this->email->message('<img src="cid:'. $cid .'" alt="photo1" />');
       $this->email->send();
}


Hi, your query was about using a template and here you are not using one. I am using a template and struggling to get the images embedded. Appreciate if you could help me in fixing this issue. Thanks



RE: Image Embedded Email Body - Code Igniter - Meena Sutar - 08-16-2018

Did you manage to embed image while using an email template? The above works but not in case of template. Appreciate your help.


RE: Image Embedded Email Body - Code Igniter - InsiteFX - 08-16-2018

Maybe this will help you with an email template.

Notice the $data array...

How to send email using HTML templates in Codeigniter