我在Cordova上开发了一个应用程序,并且使用php mailer,该客户端将允许客户将带有照片的消息发送给公司。
我使用此代码,但有时电子邮件会变成垃圾邮件(gmail)。 雅虎一直是垃圾邮件。
我尝试更改FROM,ADDREPLY..Etc,但问题相同。也许是密件抄送?
任何帮助将不胜感激。
<?php
require('phpmailer/class.phpmailer.php');
$TO["type1"] = "email1@gmail.com";
$TO["type2"] = "email2@yahoo.fr";
$TO["type3"] = "email3@gmail.com";
$TO["type4"] = "email4@gmail.com";
$TO["type5"] = "email5@gmail.com";
$TO["type6"] = "email6@yahoo.fr";
$TO["type7"] = "email7@yahoo.fr";
$FROM = "emailtest@gmail.com";
$EMAIL_CC = "emailtest@yahoo.fr";
$EMAIL_BCC = "jerome@test.fr";
if(!empty($_POST['appName']) && !empty($_POST['image']) && !empty($_POST['email']) && !empty($_POST['type']))
{
// SMTP avec authentification
$mail = new PHPMailer();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Port = 465;
$mail->Username = "email@gmail.com";
$mail->Password = "XXX";
// Expéditeur
$mail->SetFrom($FROM, 'Company name');
// Encodage du mail
$mail->CharSet = "utf-8";
// Message to admin
$to = $_POST['to'];
$subject = "xxxxxxxxxxxx".$_POST['appName'];
$message = "<img src='".$_POST['image']."' /><br /><br />xxxxx :<br /><br />".$_POST['comment'];
if(!empty($_POST['type'])) $message .= "<br /><br />xxx ".$_POST['type'];
if(!empty($_POST['address'])) $message .= "<br /><br />xxx : ".$_POST['address'];
if(!empty($_POST['lastname'])) $message .= "<br /><br />xxx : ".$_POST['lastname'];
//if(!empty($_POST['firstname'])) $message .= "<br /><br />xxx : ".$_POST['firstname'];
if(!empty($_POST['email'])) $message .= "<br /><br />E-mail : ".$_POST['email'];
if(!empty($_POST['phone'])) $message .= "<br /><br />Téléphone : ".$_POST['phone'];
if(!empty($_POST['uuid'])) $message .= "<br /><br />xxx : ".$_POST['uuid'];
// Destinataire
$mail->AddAddress($TO[$_POST['type']]);
$mail->AddBCC($EMAIL_CC);
$mail->AddBCC($EMAIL_BCC);
// Objet
$mail->Subject = $subject;
// Votre message
$mail->MsgHTML($message);
// Envoi
$mail->Send();
// *********************************************************************************************************
// SMTP avec authentification
$mail = new PHPMailer();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Port = 465;
$mail->Username = "xxxxx@gmail.com";
$mail->Password = "xxxx";
// Expéditeur
$mail->SetFrom($FROM, 'Company name');
// Encodage du mail
$mail->CharSet = "utf-8";
// Réponse à l'utilisateur
$to = $_POST['email'];
$subject = "xxxx ".$_POST['appName'];
$message = "xxxxxxx<br />";
$message .= "<img src='".$_POST['image']."' /><br /><br />xxxx message :<br /><br />".$_POST['comment'];
if(!empty($_POST['type'])) $message .= "<br /><br />xxx de xxx : ".$_POST['type'];
if(!empty($_POST['address'])) $message .= "<br /><br />xxx : ".$_POST['address'];
if(!empty($_POST['lastname'])) $message .= "<br /><br />xxx : ".$_POST['lastname'];
//if(!empty($_POST['firstname'])) $message .= "<br /><br />xxx : ".$_POST['firstname'];
if(!empty($_POST['phone'])) $message .= "<br /><br />Téléphone : ".$_POST['phone'];
//if(!empty($_POST['uuid'])) $message .= "<br /><br />xxx : ".$_POST['uuid'];
// Destinataire
$mail->AddAddress($to);
// Objet
$mail->Subject = $subject;
// Votre message
$mail->MsgHTML($message);
// Envoi
$mail->Send();
exit('OK');
}
else
{
exit('KO');
}
?>
提前。 杰伊