Welcome Guest, Not a member yet? Register   Sign In
Image Embedded Email Body - Code Igniter
#1

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?
Reply
#2

(This post was last modified: 08-09-2018, 03:28 AM by InsiteFX.)

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

(http:// or https://).
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

I think it is very much similar with your query follow this https://stackoverflow.com/questions/3184...odeigniter
Reply
#4

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();
}
Reply
#5

(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
Reply
#6

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

(This post was last modified: 08-16-2018, 08:18 AM by InsiteFX.)

Maybe this will help you with an email template.

Notice the $data array...

How to send email using HTML templates in Codeigniter
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB