Send HTML email with background image and text over the image

0

I am making a website where the customer registers his email and when registering he will automatically receive an email with a newsletter.

To send this email I'm using PhpMailer

<?php

require 'PHPMailer/PHPMailerAutoload.php';

$email = $_POST['email'];


$Mailer = new PHPMailer();

//Define que será usado SMTP
$Mailer->IsSMTP();

//Enviar e-mail em HTML
$Mailer->isHTML(true);

//Aceitar carasteres especiais
$Mailer->Charset = 'UTF-8';

//Configurações
$Mailer->SMTPAuth = true;
$Mailer->SMTPSecure = 'tls';

//nome do servidor
$Mailer->Host = 'servidor.com.br';
//Porta de saida de e-mail
$Mailer->Port = 30;

//Dados do e-mail de saida - autenticação
$Mailer->Username = '[email protected]';
$Mailer->Password = 'MinhaSenha';

//E-mail remetente (deve ser o mesmo de quem fez a autenticação)
$Mailer->From = '[email protected]';

//Nome do Remetente
$Mailer->FromName = utf8_decode('Agência');

//Assunto da mensagem
$Mailer->Subject = utf8_decode('Seja bem-vindo');

//Corpo da Mensagem
$Mailer->Body = utf8_decode('<div style="background-color:#e6f8fe;">
  <!--[if gte mso 9]>
  <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
    <v:fill type="tile" src="http://agencia306.com.br/blog-306/img/como-aproximar/1.jpg"color="#e6f8fe"/>
  </v:background>
  <![endif]-->
  <table height="100%" width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
      <td valign="top" align="left" background="http://agencia306.com.br/blog-306/img/como-aproximar/1.jpg">    <h1>Em fase de construção </h1>   </td>
    </tr>
  </table>
</div>');

//Corpo da mensagem em texto
$Mailer->AltBody = 'conteudo do E-mail em texto';

//Destinatario
$Mailer->AddAddress($email);

if($Mailer->Send()){
    echo "<script>alert('E-mail enviado com sucesso');history.back();</script>";
}else{
    echo "<script>alert('Erro no envio do e-mail: " . $Mailer->ErrorInfo . " ');history.back();</script>";
}

?>

The code is running smoothly, email arrives smoothly for the person who signs up. But I have two problems:

1 ° Problem: Sending this way, I test in my Yahoo email, the email goes without problem. But the main purpose of sending a background image and text over that image is not working. This is just going text.

2nd Problem: You are going to Span. I researched and read that using PhpMailer this was not going to happen. But it's going to Span.

    
asked by anonymous 27.04.2017 / 16:25

2 answers

2

First thing you need to know to create email marketing is that the patterns are the oldest in HTML, from the time you did not use CSS to format things. So to make a text with background image you must put the text inside a table, and use the background attribute of the table tag.

<table width="100%" border="0" cellspacing="0" cellpadding="20" background="http://www.seudominio.com.br/img/background_image.png">
<tr>
    <td>
        <p>Content on a pretty background image.</p>
    </td>
</tr>
</table>

In addition to changing fonts you will need to use the <font> tag, for margins you will need to use the padding or spacing of the table itself. Email marketing is boring to put together, but it's how we should do it.

This is why people often create as an image and place the text in an alt attribute of the image.

Not to be taken as spam you should make sure of some things. For example:

  • The text can not be keywords detected by anti spam, such as: "buy", "promotion" or similar words.
  • Domain must have SPF and DKIM configured correctly authorizing the sending server
  • You must have some text in your email, not just images
  • You should send each email individually, without thousands of copy addresses
  • The sending server must be trusted and the sending tools also, such as: Amazon SES , Mailchimp , Madmimi
  • You also need to have a lot of faith:)
27.04.2017 / 16:45
0

Good morning, because of limitation of several email readers, you can not use backgroud, I've already broken my head to make it work however there is no way you guarantee, in gmail it works, however in non-outlook, and in several readers phone does not work.

About spam, it goes far beyond the reputation of your email server and your email address. However communication strategies in email can sometimes solve your problem, it is worth investing some time in these email issues.

    
27.04.2017 / 16:43