I have created an HTML page with inline css and provided logo as inline css background
<div id="logo_image" style='background: url("<?=base_url();?>assets/images/img2.png") no-repeat scroll 0 0 / 150px auto rgba(0, 0, 0, 0);height: 73px;margin: -15px 0 0;position: absolute; width: 160px;'></div>
I have also tried using
<img src="<?=base_url();?>assets/images/img2.png" style="float: left;margin-top: -11px;width: 100px;margin-left:10px;" />
The mail function used is as below
$this->email->clear();
$this->email->set_newline("\r\n");
$this->email->set_mailtype("html");
$this->email->from('example@gmail.com','example');
$this->email->to($user['email']);
$this->email->subject('Thank You');
$this->email->message($this->load->view('emails/register', $name, TRUE));
$name
contains some variables to be displayed in the template register.php
Everything works well except for logo not being displayed
PS : i am working on localhost
.
the answer is in ur own question. you are sending mail from localhost/ur localmachine. when u send mail with image or imported css or js which are on ur localmachine, gmail or anyother cannot interprete that as a proper url.
so what it does is appends its own url before it like https://ci3.googleusercontent.com/proxy/..some link..#http://localhost/assets/images/img2.png
so ur image will not be displayed until you upload the project on a domain.
Instead of using:
<img src="<?=base_url();?>assets/images/img2.png" style="float: left;margin-top: -11px;width: 100px;margin-left:10px;" />
try using:
<img src="<?php echo base_url();?>assets/images/img2.png" style="float: left;margin-top: -11px;width: 100px;margin-left:10px;" />
I replaced <?= ... ?>
with the full php tag <?php ?>
.
I know that it causes problems sometimes, so I always use the full tag.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.