CodeIgniter Forums

Full Version: Image Embedded Email Body - Code Igniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
For emails you need the full path to the image file.

(http:// or https://).
I think it is very much similar with your query follow this https://stackoverflow.com/questions/3184...odeigniter
Thank you all for your help.

I was able to sort through the documentation.

https://www.codeigniter.com/user_guide/l...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();
}
(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/l...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
Did you manage to embed image while using an email template? The above works but not in case of template. Appreciate your help.
Maybe this will help you with an email template.

Notice the $data array...

How to send email using HTML templates in Codeigniter