如何在codeigniter中的电子邮件中显示图像 [英] How to display an image in email in codeigniter

查看:121
本文介绍了如何在codeigniter中的电子邮件中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

控制器

Controller

public function index(){
     send_mail('New Volunteer Form received', $this->load->view('site/email/volunteer', NULL, TRUE));
}

助手功能

以下帮助函数并使用发送电子邮件
function send_mail($ subject,$ message){

Below helper function and use send email function send_mail($subject, $message) {

    /* @var $CI CI_Controller  */
    $CI = &get_instance();
    $CI->load->library('upload');
    $CI->load->library('email');
    $CI->email->from('zbc@abc.com', 'Hello');
    $CI->email->to('abc@gmail.com');
    $CI->email->subject($subject);
    $CI->email->message($message);
    $CI->email->set_mailtype('html');
    $CI->email->attach(base_url() . 'uploads/volunteer/');
    return $CI->email->send();
}

查看

                    <td>Photo</td>
                    <td style="text-align: center"><img src="<?php base_url() ?>uploads/volunteer/<?php echo $_POST['userfile']; ?>" height="100" width="150"></td>
                </tr>


推荐答案

尝试此

$this->email->attach('/path/to/photo1.jpg', 'inline');

$message = '<td>Photo</td>';
$message .= '<td style="text-align: center">';
$message .= '<img src="<?php base_url() ?>uploads/volunteer/<?php echo $_POST['."userfile".']; ?>" height="100" width="150">';
$message .= '</td></tr>';




要使用默认处置(附件),请将第二个参数留空,否则使用自定义处置

To use the default disposition (attachment), leave the second parameter blank, otherwise use a custom disposition

这篇关于如何在codeigniter中的电子邮件中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆