我正在尝试使用内嵌图片发送此电子邮件,但图片始终作为真实附件发送:内容配置:附件。 有什么想法吗?
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mail.mydomain.com';
$config['smtp_port'] = 25;
$config['smtp_user'] = 'noreply@mydomain.com';
$config['smtp_pass'] = 'password';
$config['mailtype'] = 'html';
$config['newline'] = "\r\n";
$this->load->library('email', $config);
$this->email->from('noreply@mydomain.com', 'Mydomain');
$this->email->to('email@mydomain.com');
$this->email->subject('Subject');
$image = getcwd() . '/image.jpg';
$this->email->attach($image, 'inline');
$message = '<!DOCTYPE html><head><meta charset="utf-8"><title></title></head><body>';
$message .= '<img src="cid:' . $image . '" /><br /><br />';
$message .= 'Hi there!<br /><br />';
$message .= '</body></html>';
$this->email->message($message);
$this->email->send();
答案 0 :(得分:0)
加载email
库后,只需添加此行。
$this->email->set_mailtype("html");