Select image - phpmailer submission

0

I'm trying to send an email through phpmailer with a signature image at the end, in case I have this select to select the desired signature.

                        <select class="form-control" id="assinatura" name="assinatura">
                            <option value="">Seleciona uma opção</option>
                            <option value="suporte">Suporte</option>
                            <option value="alan">Alan</option>
                            <option value="ricardo">Ricardo</option>
                            <option value="rogerio">Rogerio</option>
                            <option value="gislei">Gislei</option>
                        </select>

And this is the code in phpmailer, it does not send the image at the end.

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <html>
            <head>
                <title>E-mail</title>
                <meta charset="utf-8">
            </head>
            <body>

            <?php
                date_default_timezone_set('America/Sao_Paulo');

        require_once('./phpmailer/class.phpmailer.php'); 
        require './phpmailer/PHPMailerAutoload.php';

        //variaveis - para envio


        $sistema            = $_POST['sistema'];
        $email_smart        = $_POST['email'];
        $senha_smart        = $_POST['senha'];
        $remetent_smart     = $_POST['remetent'];
        $nome_destinatario  = $_POST['nome_destinatario'];
        $destinatario       = $_POST['destinatario'];
        $assunto            = $_POST['assunto'];
        $mensagem           = $_POST['editor1'];
        $arquivo            = $_FILES['arquivo'];
        $assinatura         = $_POST['assinatura'];


        if($assinatura == 'suporte'){
            $img_assinatura = ("<img src'http://www.meusite.com.br/email/img/assinaturas/ass1.jpg'>");
        } else {
            echo "assinatura não selecionado";
        }
        }

        $template = str_replace('%assinatura%', $img_assinatura, $template);
        $template = str_replace('%mensagem%', $mensagem, $template);

        //inicio PHPMailer
        $mail = new PHPMailer; // instancia a classe PHPMailer

        $mail->IsSMTP();

        //configuração do usuário do email
        $mail->Host         = "smtp.gmail.com";
        $mail->SMTPAuth     = true;
        $mail->SMTPSecure   = "ssl"; 
        $mail->Port         = '465';
        $mail->Username     = $email;
        $mail->Password     = $senha;

        //remetente
        $mail->From = $email; 
        $mail->FromName = $remetent; 

        //destinatrio
        $mail->AddAddress($destinatario);

        //enviar a mensagem com anexo
        $mail->CharSet = 'utf-8';
        $mail->Subject = $assunto; 
        $mail->MsgHTML($template);
        $mail->AddAttachment($arquivo['tmp_name'], $arquivo['name']  );

        $headers = "MIME-Version: 1.0\n";   
        $headers .= "Content-type: text/html; charset=iso-8859-1\n";  



        // Controle de erro ou sucesso no envio
        if (!$mail->Send())
        {
             echo "Erro de envio: " . $mail->ErrorInfo;
         }
        else{

            echo "Mensagem enviada com sucesso!";
        }
        ?>

        </body>
        </html>
    
asked by anonymous 16.02.2018 / 13:52

2 answers

1

It probably does not appear because it recognizes Body as text and not as HTML. In the PHPMailer configuration, before sending the message ( $mail->Send() ) add the line:

$mail->IsHTML(true);

This should resolve.

    
16.02.2018 / 21:00
0

I was able to resolve this way.

if($assinatura == 'suporte'){
$img_assinatura = "./img/assinaturas/suporte.jpg";
} else {
echo "assinatura não selecionado";
}

and in the template I put this to replace only the path.

 <img src="%assinatura%" align="center" style="display: block;" alt="">
    
16.02.2018 / 16:02