如何使用phpmailer在html邮件中正确添加图像?

This is a part of email content

Html:

<table border="0" cellpadding="30" cellspacing="0" width="100%">
 <tr>
  <td align="center" valign="top" class="textContent">
   <img src="img/logo.png" style="height: 100px; margin-top: 13px;" alt="" />
    <br>
    <br>
    <div style="font-family:Helvetica,Arial,sans-serif;font-size:13px;color:#828282;margin-top:-23px;text-align:center;line-height:120%;">LAZOS S.A</div>
    </td>
    </tr>
</table>

The email look of this way:

enter image description here

But I can't display logo.png up "LAZOS S.A"

Inside img folder is logo.png

enter image description here

Inside the folder mailAvisoSinTareasReg is contenido.html

This is my php code using phpmailer:

<?php

require "vendor/autoload.php";

    class HelperMail{

      private $oPhpMailer;

        function __construct(){

            $this->oPhpMailer = new PHPMailer();
            $this->oPhpMailer->isSMTP();
            $this->oPhpMailer->SMTPDebug = 2;
            $this->oPhpMailer->Debugoutput = 'html';
            $this->oPhpMailer->SMTPSecure = 'tls';
            $this->oPhpMailer->SMTPAuth = true;

        }
                public function mailFrom($from,$usuario){
                  $this->oPhpMailer->setFrom($from, $usuario);             
                }
                public function mailPort($puerto){
                  $this->oPhpMailer->Port = $puerto;   
                }
                public function mailUsuario($usuario){
                  $this->oPhpMailer->Username = $usuario;   
                }
                public function mailPassword($pass){
                  $this->oPhpMailer->Password = $pass;       
                }
                public function mailHost($host){
                  $this->oPhpMailer->Host = $host;      
                }
                public function mailSubject($subject){
                  $this->oPhpMailer->Subject = $subject;       
                }
                public function mailAddress($address){
                  /*$this->oPhpMailer->addAddress($address);*/     
                  $this->oPhpMailer->addAddress('jean.bergeret.f@gmail.com');
                }
                public function mailAltBody(){
                  $this->oPhpMailer->AltBody = 'This is a plain-text message body';     

                }

                public function setData ($usuarios){ 

                  $html = '';
                  $htmlmail = file_get_contents('helpers/mailAvisoSinTareasReg/contenido.html'); 
                  foreach($usuarios as $sKey=>$oValue){
                      $html .= '<tbody><tr><td width="50%" align ="center">'.$oValue['nombre_usuario']." ".$oValue['apellido_usuario'].'</td><td width="50%" align ="center" >'.$oValue['rut_usuario'].'</td></tr></tbody>';
                  }
                  $htmlReplace = str_replace("<tr><td>datos</td></tr>",$html,$htmlmail);  
                  $htmlReplaceFecha = str_replace("fecha",$this->setFecha(),$htmlReplace);
                  $this->oPhpMailer->msgHTML($htmlReplaceFecha);
                  $this->sendMail();
                }

                public function sendMail(){

                  if (!$this->oPhpMailer->send()) {
                            echo "Mailer Error: " . $this->oPhpMailer->ErrorInfo;
                        } else {
                            echo "Message sent!";
                        }             
                }

        private function setFecha(){

            date_default_timezone_set("America/Santiago");
            $now = time();
            putenv("TZ=America/Santiago");
            $fecha=date("Y-m-d H:i:s",$now);
            $date=date("d/m/Y", strtotime($fecha));
            return $date;

        }

        }
?>

Sorry by my english.

You can encode your image and use it as img src

$imgFullpath = '/home/myImage.png';
$imgType     = 'png';
$base64      = 'data:image/' . $imgType . ';base64,' . base64_encode($imgFullpath);

....

when you build your HTML :

<img src="' . $base64 . '">;

It looks like you haven't attached the image itself to the email. You need to explicitly do this, otherwise your src refers to nothing. Add this line before you call ->send();.

$this->oPhpMailer->addAttachment('helpers/img/logo.png', 'img/logo.png');

I have used a relative path (1st param) to access the image file and then called it the name (2nd param) which you have used as a reference in your html. PHPMailer should sort out the rest.