使用邮件程序发送垃圾邮件通过php发送电子邮件

时间:2017-04-03 11:05:09

标签: php email

我正在通过PHP Mailer类发送电子邮件。我尝试了很多次,但每次都收到垃圾邮件。我想将它用于whatuser。我正在使用PHP Mailer类并收到垃圾邮件。请帮忙,我的代码如下:

require_once("PHPMailer-final/class.phpmailer.php");
$admin_email="support@example.com";

$admin_email_caption="example.com";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host     = "mail.example.com"; // SMTP servers
$mail->Port = 26;
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Mailer   = "smtp";
$mail->Username = "support@example.com";  // SMTP username
$mail->Password = "123456789"; // SMTP password
$subject=$subject_mem;
$cs_email=$to_mem;
$body_admin = $body_mem;
$headers ="From:".$admin_email_caption."<".$admin_email.">\nReply-To:".$admin_email."\nContent-Type:text/html";
$mail->From = $admin_email;
$mail->FromName = $admin_email_caption;
$mail->AddReplyTo($admin_email);
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $body_admin;
$mail->AltBody = "This is alt body.";
$mail->AddAddress($cs_email);
if(!$mail->Send())
    @mail($cs_email,$subject,$body_admin,$headers) or die("not send");
//echo $cs_email."<br>";
$mail->ClearAddresses();
$mail->ClearAttachments();
$mail=NULL;

1 个答案:

答案 0 :(得分:0)

  

您应该检查 SMTP 配置。

可能SMTP配置不正确。因此,您的mail()功能正常运行。并且mail()函数有一些缺失headers。示例charset。标题丢失或无效是在spam

中收到邮件的另一个原因

以下是PHPMailer Configurations

的详细信息

取消注释用于调试SMTP配置的行//$mail->SMTPDebug = 3;