CodeIgniter Forums
Email html with images - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Email html with images (/showthread.php?tid=69252)



Email html with images - Eduardo Faria - 10-27-2017

Hi everyone,

I am trying to send an email with a hml message that contain images (e.g. logo image). How can i do that?

I tried to attach the image and reference only the name of file in html img..did not work. I tried to have the image from a link, but did not work because the path in site with images can't be accessed directly.

Thanks.


RE: Email html with images - Wouter60 - 10-27-2017

Include the same url as when you would display the image on your website.

E.g.:
PHP Code:
<img src="<?= base_url('./media/images/example.jpg');?>" /> 

Put the content of your e-mail inside a view.
Load the view as a string:

PHP Code:
$msg $this->load->view('email/example1',TRUE);

$this->load->library('email');
$this->email->to('[email protected]');
$this->email->from('[email protected]');
$this->email->subject('Test');
$this->email->message($msg);
$this->email->send(); 



RE: Email html with images - ivantcholakov - 10-27-2017

A image set through URL is possible.

I guess you want an attached image file to be shown as an embedded image within the text? Like:
Slogan <img src="cid:logo_src" /> Text Text ... ?
I haven't checked recently, but I doubt that such a feature is supported by CI_Email class.


RE: Email html with images - Eduardo Faria - 10-27-2017

(10-27-2017, 02:02 PM)ivantcholakov Wrote: A image set through URL is possible.

I guess you want an attached image file to be shown as an embedded image within the text? Like:
Slogan <img src="cid:logo_src" /> Text Text ... ?
I haven't checked recently, but I doubt that such a feature is supported by CI_Email class.

Thanks Ivantcholakov and others,

I found the problem... after put site online, it worked fine. One problem was that the files are case sensitive and the picture extension was .PNG, while I was trying to access .png.!


RE: Email html with images - shf - 12-16-2017

Thank you, my problem was that it was resolved