在我的代码中,为什么图像不通过php codeigniter加载到电子邮件中?

时间:2017-03-16 09:38:43

标签: php codeigniter

图片必须显示在右上角,但它没有显示,我不知道为什么它没有显示,在我的代码下面,通过它并帮助我

这是我的观看页面代码

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Ecommerce | Forgot Password</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <style>
            .bg{background:#ffffff;border-top:5px solid #f63f3f;border-bottom:5px solid #f63f3f;width:70%;border-left: 1px dotted #bdb8b8;border-right: 1px dotted #c7c0c0; }
            .img-text{padding:15px;background:#f5f5f5;border-bottom: 2px solid #c8c8c8;height: 55px;}
            .img-text .pleft{float:left;margin: 0 auto;}
            .img-text .pright{float:right;margin: 0 auto;}
            .center{text-align:center;}
            .pright img{width: 180px;height: 45px;}
            .otp{background: #f63f3f;border-radius: 5px;display: inline;text-align: center;margin: 0 0% 0 40%;padding: 6px;color: #fff;letter-spacing: 3px;}
            .content{padding: 2%;margin: 0 0 18px 0;}
            .bold{color:#f63f3f;font-weight:700;text-transform:capitalize;}
        </style>
    </head>
    <body>
        <div class="bg">
            <div class="img-text">
                <p class="pleft">Password Reset</p>
                <p class="pright"><img src="<?php echo ('base_url'); ?>images/teralogo.png" /></p> 

            </div>
            <div class="content">
                <p class="center">Someone recently requested that the password be reset for <span class="bold">prasanthi473</span></p>
                <p class="center">To reset your password use the following OTP</p>
                <p class="otp"><?php echo $this->session->userdata('otp') ?></p>
            </div>
        </div>
    </body>
</html>

这是我在控制器中的功能

public function sendmail() {


        $this->form_validation->set_rules('email', 'Email or number', 'required|min_length[10]|max_length[30]');
        if ($this->form_validation->run() == FALSE) {
            $this->load->view('login');
        } else {

            $data['email'] = $this->input->post('email');

            $findemaill = $this->Login_model->getUserInfoByEmail($data['email']);



            if (!empty($findemaill)) {
               // $this->Login_model->getUserInfo('$id');
               // $this->session->set_userdata('forgot_password_flag', 'yes');
                $emailTo = $this->input->post('email');
                   $this->session->set_userdata('findemaill',  $emailTo);
                  //  $this->session->userdata('findemaill');

                $data['result'] = $this->Login_model->forgot_pass_retrive($emailTo);
                $id = $data['result']->id;
                $this->session->set_userdata('idd', $id);



                $six_digit_random_number = mt_rand(100000, 999999);

                $this->session->set_userdata('otp', $six_digit_random_number);

                $this->load->model('Login_model');

                $pass['pass'] = $this->Login_model->forgot_pass_retrive($emailTo);

                $config['protocol'] = 'smtp';

                $config['smtp_host'] = 'ssl://smtp.gmail.com';

                $config['smtp_port'] = '465';

                $config['smtp_timeout'] = '7';

                $config['smtp_user'] = 'tworkreport@gmail.com';

                $config['smtp_pass'] = '8722248936';

                $config['charset'] = 'utf-8';

                $config['newline'] = "\r\n";

                $config['mailtype'] = 'html'; // or html

                $config['validation'] = TRUE; // bool whether to validate email or not      

                $this->email->initialize($config);
                $this->email->from('tworkreport@gmail.com', 'Terasukhintrade');
                $this->email->to($emailTo);


                $this->email->subject('Reset your password');

                $body=$this->load->view('forgotmailer',$data,TRUE);

                $this->email->message('Click on link to reset your password '.$body );

                $this->email->send();

                echo $this->email->print_debugger();

                $this->load->view('login',$data);
            } else {

                $this->session->set_flashdata('message', ' Email address not found!');
                $this->load->view('login',$data);
            }

        }
    }

this is the output i am getting

1 个答案:

答案 0 :(得分:1)

我认为您应该在img标记中使用<?php echo base_url(); ?>而不是<?php echo ('base_url'); ?>。在CodeIgniter base_url()函数中,返回服务器的完整URL。

更新:尝试这样

<img src="<?= base_url('images/teralogo.png') ?>" />

要使用base_url(),您必须加载url帮助程序。