0
I registered three emails in my database, but when I send the email it falls into the spam box.
I don’t know what I should do not to fall as spam.
In case the content of the email is an email marketing html. (containing photos and content written in html).
In case the code is very simple, I send a form the HTML and caught by PHP.
The host used to send is: http://hostbase.com/
I don’t want a guarantee that the email will never fall into the spam box, but why it is falling into the spam box.
This is not a question of opinion, but of experience, so if you have no experience of why this is happening, please do not answer.
I believe I was not clear on the question, so I decided to edit it.
The question is simple. Why do emails fall as spam in this code? What do I need to change in the code in order not to fall as spam? The problem of falling as spam may be the HTML layout?
<?php
include_once "conexao.php";
$email = $_POST['email'];
$nome = $_POST['nome'];
$assunto = $_POST['assunto'];
$arquivo = $_FILES['arquivo'];
$arquivo = file_get_contents($_FILES['arquivo']['tmp_name']);
$sql = "SELECT `id`, `email` FROM `mailmarketing` ";
$query = $mysqli->query($sql);
echo '<table><tr><td>E-mail: </td></tr>';
while ($dados = $query->fetch_array()) {
$destino = $dados['email'];
// É necessário indicar que o formato do e-mail é html
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$nome.' <'.$email.'>';
//$headers .= "Bcc: $EmailPadrao\r\n";
echo '<tr><td>' . $dados['E-mail'] . '</td><td>';
$enviaremail = mail($destino, $assunto, $arquivo, $headers, "-f$email");
if($enviaremail){
echo "<b>E-mail enviado com sucesso!</b>";
//echo " <meta http-equiv='refresh' content='1;URL=index.php'>";
} else {echo "<b>erro ao enviar o e-mail!</b></br>";}
echo "</td></tr>";
}//echo 'Registros encontrados: ' . $query->num_rows;
echo "</table>";
?>
Felipe, I don’t think you understand the point of fellow @Sneepsninja. The point is, it doesn’t matter if it’s the user or the filtering system that sends your email to the spam box. You can’t guarantee on your side that the message is never marked as SPAM. It is not your/your system’s assignment, simple as that. What you can do is follow best practices to try not to characterize your email as spam. Your two questions are somewhat confusing in the sense that they do not ask for such practices, but rather a way of guaranteeing something for which there are no guarantees.
– Luiz Vieira
Felipe, an interesting tip is to use SMTP or a service like Mandrill for submissions, and configure the dkim and Spf of the domain. This brutally changes the chances of an email being considered spam.
– Fernando Cordeiro
Using SMTP is very interesting, our colleague Diego Souza sent a code from github to send emails using SMTP (Phpmailer) Thank you very much to everyone who helped me, but I believe that the question has become much more complex than I imagined. I just wanted to make sure that e-mail didn’t fall into the spam box. But now I believe I have gained some more knowledge that I can put into practice for an email marketing. But the focus wasn’t email marketing, I just wanted to know why the email was falling into the spam box and how could I fix it.
– Felipe Jorge
This question is being discussed in the Meta: http://meta.pt.stackoverflow.com/questions/3791/post-markedas duplicated by%C3%A9m-n%C3%A3o-necess%C3%A1riamente-similar
– Luiz Vieira