我正在使用PHPMailer
向我的用户发送完整的html文件的注册确认电子邮件。除了没有加载图片外,电子邮件显示完美。
这里我附上我的PHP代码:
$mail = new PHPMailer(true);
$mail->CharSet = 'utf-8';
$mail->setFrom($this->Settings->SUPPORT_EMAIL_ADDRESS);
$mail->AddAddress($email);
$mail->Subject = dblang('registration_confirm_email_subject');
if (file_exists(APPPATH . '/views/email/registration/confirm.txt.' . $this->lang->lang() . '.php')) {
$mail->AltBody = $this->load->view('_email/registration/confirm.txt.' . $this->lang->lang() . '.php',
$emailData, true);
}
$mail->isHTML(true);
$mail->Body = $this->load->view('_email/registration/confirm.html.' . $this->lang->lang() . '.php',
$emailData, true);
if($mail->send()) {
swal_success('registration_email_send_title', 'registration_email_send_text');
redirect(site_url('home'));
}
这里我放了一部分html代码。我试过相对和绝对的url为图片路径:
<img src="../../../../../../bets/assets/email/welovesports.png" alt="We Love Sports" border="0" width="290" height="92"
style="display: block;border: none;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;">
答案 0 :(得分:0)
因为你已经尝试过没有运气的绝对网址
查看代码参考../../../../../../bets/assets/email/
我建议将该图片复制到 public_html - &gt;的根源。 /public_html/welovesports.png
然后将其引用为<img src="http://your-domain.test/welovesports.png">
因为没有。您的代码建议的目录,可能使参考正确的路径变得困难
http://i.imgur.com/RDz0KBs.png
)