Hector Landete Hector Landete - 1 year ago 184
HTML Question

PHPMailer html not showing images

I'm using

to send the registration confirm email to my users with a full html file. The email shows perfectly except for the pictures are not loaded.

Here I attach my php code:

$mail = new PHPMailer(true);
$mail->CharSet = 'utf-8';
$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->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');

Here I put a part of the html code. I've tried with relative and absolute urlfor the pictures path:

<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;">

Answer Source

Since you've tried absolute urls with no luck.
looking on your code reference ../../../../../../bets/assets/email/
I suggest copy that image to very root of public_html -> /public_html/welovesports.png
and then reference it as <img src="http://your-domain.test/welovesports.png"> because the no. of directories your code suggests, can make it difficult to reference the correct path

OR Alternatively
you can use http://imgur.com/upload and host your image with them.
and on the gallery page of that image copy its direct link to use it
(it will be like http://i.imgur.com/RDz0KBs.png)
eg: http://i.imgur.com/RDz0KBs.png

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download