简体   繁体   中英

What can I do to stop the mail I send from being classified as junk?

I have a PHP script which permit me to send an email with a PDF by a click on a button. The script works but i received the mail in a junk email . I want to know why ? And what can i do for receiving the mail normaly.

$mail_to = "brian.millot@live.fr"; //Destinataire  
$from_mail = $dataed['EDI_FROM']; //Expediteur  
$from_name = "Nom"; //Votre nom, ou nom du site  
$reply_to = $_POST['edi_from']; //Adresse de réponse  
$subject = "Nouvelle commande";      
$file_name = $_POST['urlpdfvcmd'].".pdf";  
$path = "temp/";  
$typepiecejointe = filetype($path.$file_name);  
$data = chunk_split( base64_encode(file_get_contents($path.$file_name)) );  
//Génération du séparateur  
$boundary = md5(uniqid(time()));  
$entete = "From: $from_mail \n";  
$entete .= "Reply-to: $from_mail \n";  
$entete .= "X-Priority: 1 \n";  
$entete .= "MIME-Version: 1.0 \n";  
$entete .= "Content-Type: multipart/mixed; boundary=\"$boundary\" \n";  
$entete .= " \n";  
$message  = "--$boundary \n";  
$message .= "Content-Type: text/html; charset=\"iso-8859-1\" \n";  
$message .= "Content-Transfer-Encoding:8bit \n";  
$message .= "\n";  
$message .= "Bonjour ".$infcmd['CMD_CLT_LIV_NOM'].", <br /><br />
Veuillez trouver ci-joint le détail de votre commande no ".$infcmd['CMD_CODE'].". <br /> 
Cordialement. <br /><br />
".$sign['CST_SOC_NOMSOC']."<br />
".utf8_decode($sign['CST_SOC_ADRESSE_RUE1'])."<br />
".utf8_decode($sign['CST_SOC_ADRESSE_RUE2'])."<br />
".utf8_decode($sign['CST_SOC_ADRESSE_CP'])." - ".utf8_decode($sign['CST_SOC_ADRESSE_VILLE'])."<br />
Tel : ".$sign['CST_SOC_ADRESSE_TEL']."<br />
Fax : ".$sign['CST_SOC_ADRESSE_FAX']."";  
$message .= "\n";  
$message .= "--$boundary \n";  
$message .= "Content-Type: $typepiecejointe; name=\"$file_name\" \n";  
$message .= "Content-Transfer-Encoding: base64 \n";  
$message .= "Content-Disposition: attachment; filename=\"$file_name\" \n";  
$message .= "\n";  
$message .= $data."\n";  
$message .= "\n";  
$message .= "--".$boundary."--";  

mail($mail_to, $subject, $message, $entete); 

There are a myriad of reasons that email is considered junk or spam. I'm assuming the mail account your php server uses to send email is not the same as what you are saying is the "FROM" account in the actual email. This is pretty much a trigger in most email clients that you are sending spam and trying to make it look like it's from a reputable source.

There is a strong reasion for your message to be marked as a junk. The mail server validates the ip address from source. "Every mail should be delivered by mail server only". If your message not passes through the mail server, then you mail will be thraeted as junk.

If I am understanding you right and you are saying the email was received but sent to the Junk Box, then I think the problem is with your email client, not the code. The email client is what determines if a mail is junk or not, not the code that constructs the email.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM