The mail shows me the base 64 code instead of the embedded images

I can’t insert images of my project locally in my email

conversion to base 64

    $logo_ayto = Yii::getAlias('@app/web/img/lg_ayuntamiento.png');
    $logo_lanzadera = Yii::getAlias('@app/web/img/lg_lanzaderas3.png');
     
    $type_log_ayto = pathinfo($logo_ayto, PATHINFO_EXTENSION);
    $type_log_lanzadera = pathinfo($logo_lanzadera, PATHINFO_EXTENSION);

    $data_log_ayto = file_get_contents($logo_ayto);
    $data_log_lanzaderas = file_get_contents($logo_lanzadera);

    $logo_ayto_base64 = 'data:image/' . $type_log_ayto . ';base64,' . 
         base64_encode($data_log_ayto);
    $logo_lanzaderas_base64 = 'data:image/' . $type_log_lanzadera . ';base64,' . 
      base64_encode($data_log_lanzaderas);

the email html

$html = ’


            </head>
            <body style="max-width:1200px;">

            <header width="100%" align="center">
                    <img src="'.$logo_ayto_base64.' width="100%" border="0" alt="" />
                    <label style="padding:40px 100px 40px 100px; font-weight: bold;font-size:30px;">LANZADERA TALENTOS</label>
                    <img src="'.$logo_lanzaderas_base64.'" width="100%" border="0" alt=""  />
                   
            </header>

            <main width="100%" align="center">
                    <div style="text-align:center;color:#c62828;font-weight: bold;font-size:30px;">
                        <p style="">¡Nuevo Talento! </p>
                    </div>
                    <div style="text-align:center;font-size:20px">
                        <p>Un nuevo usuario quiere darse de alta en nuestra Web,<p/> 
                        <p>sólo tienes que autorizarlo.</p>
                    </div>
                    <div style="text-align:left;margin-left:400px;margin-top:30px;font-size:20px;font-weight: bold;">
                        <p>Sus datos son:  </p>
                    </div>
                    <div style="font-size:20px;text-align:left;margin-left:500px">
                      
                            <p>Año de su Lanzadera: <i style="font-weight: bold">'. $model->fechalanzadera.'</i></p>
                            <p>Nombre: <i style="font-weight: bold">'.$model->nombre.'</i></p>
                            <p>Apellidos: <i style="font-weight: bold"> '.$model->apellidos.'</i></p>
                            <p>Email: <i style="color:blue;font-weight:bold">'.$model->email.'</i></p>
                            <p>Teléfono: <i style="font-weight: bold">'.$model->movil.'</i></p>
                       
                    </div>    

            </main>

            <footer width="100%" align="center" style="margin-top:35px;">
                    <button type="button" class="btn btn-primary btn-lg" style="background-color:blue;text-align: center; font-size: 22px; font-family: arial; font-weight: bold; padding: 30px 30px 30px 30px;">Autoriza el Registro</button>             
                    <p style="padding-top:15px;">(este es un enlace a la página de la Web donde puede autorizar el registro de este usuario)</p>

            </footer>


            </body>
            </html>';

sending the email
$contenido = Yii::$app->mailer->compose();

            $contenido->setTo([Yii::$app->params['senderEmail'] => Yii::$app->params['senderName']]);
            $contenido->setFrom([Yii::$app->params['senderEmail']]);
            $contenido->setReplyTo([Yii::$app->params['senderEmail']]);
            $contenido->setSubject('Nuevo Preregistro Talento');
            $contenido->setTextBody('');
            $contenido->setHtmlBody($html);
            $contenido->send();

https://swiftmailer.symfony.com/docs/messages.html#embedding-inline-media-files

I still can’t embed images in my email.

SiteRegister
$image_ayto = Yii::getAlias("@webroot/img/lg_ayuntamiento.png");
$image_lanza = Yii::getAlias("@webroot/img/lg_lanzaderas3.png");
$contenido = Yii::$app->mailer->compose(’@app/mail/layouts/correo_solicitud’, [
‘fechalanzadera’ => $model->fechalanzadera,
‘nombre’ => $model->nombre,
‘apellidos’ => $model->apellidos,
‘email’ => $model->email,
‘movil’ => $model->movil,
‘logo_ayto’ => $image_ayto ,
‘logo_lanza’ => $image_lanza
]);
$contenido->setTo([Yii::$app->params[‘senderEmail’] => Yii::$app->params[‘senderName’]]);
$contenido->setFrom([Yii::$app->params[‘senderEmail’]]);
$contenido->setReplyTo([Yii::$app->params[‘senderEmail’]]);
$contenido->setSubject(‘Nuevo Preregistro Talento’);
$contenido->setTextBody(’’);
$contenido->send();
And this is my view “correo_solicitud.php” in mail/layout

<?php use yii\helpers\Html; use yii\swiftmailer\Message; $contenido = new Message(); ?>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
  <title>Nuevo PreregistroTalento Lanzadera</title>
  </head>
  <body style="max-width:1200px;">    
    <header width="100%" align="center">          		
     <img src="<?= $contenido->embed($logo_ayto); ?>" width="150px" border="0" alt="no image" />
    <label style="padding:40px 100px 40px 100px; font-weight: bold;font-size:30px;">LANZADERA TALENTOS</label>
  <img src="<?= $contenido->embed($logo_lanza); ?>" width="120px" border="0" alt="no image"  />
                 
            </header>

$fechalanzadera, $nombre, $apellidos, $email, $movil, It shows them perfectly but the images $logo_ayto and $logo_lanza, do not embed them.

Check if Yii::getAlias("@webroot/img/lg_ayuntamiento.png") is really showing you absolute path to the image.

Indeed, with that alias, I could not get the absolute path. I have tried with the absolute path directly “http: // …”
and still does not display the embedded image.

I am not sure if it will be a gmail problem because I have tried in all the ways and the embedded images does not show them and with the absolute url it does show them. The problem is, I don’t want the absolute url to show for security.

Absolute path on server - not the URL, so it should not start with http. And the path will not be displayed when properly embedded.