dsi36131 2017-11-07 20:38
浏览 42

从我的域发送带有phpmailer的电子邮件到垃圾邮件[重复]

I'm trying to send emails using phpmailer but every mail that i sended, finish in the spam folder.

This is the code

require("phpmailer/class.phpmailer.php"); // or wherever you put phpmail.class

$username="xxx";
$password="yyy";

$mail = new PHPMailer;
$mail->isMail();
$mail->IsHTML(true);
$mail->SMTPDebug = 4;
$mail->setFrom('news@lexvirtual.cl', 'Lexvirtual');
$mail->addAddress("roasdf@gmail.com", "hola");
$mail->Subject = 'Nueva postulación lexvirtual.cl';
$mail->AddEmbeddedImage('../assets/img/common/lexvirtual_logo.png', 'logoimg', '../assets/img/common/lexvirtual_logo.png');

$body = file_get_contents('email_templates/register.php'); 
$body = str_replace('%username%', $username, $body);
$body = str_replace('%password%', $password, $body);
$message = $body;
$mail->msgHTML($message);

if ($mail->send()) {
echo "email enviado";
} else {
echo "email no enviado";
}

I'm sending the email from my domain that is lexvirtual (the same domain that i'm using to send the email (news@lexvirtual.cl)).

Now i'm using a template using html but when i send a email using only text, still send the email to spam. I tried reading other questions about this problem,but still can't fix the issue.

Someone can help me please?

</div>
  • 写回答

1条回答 默认 最新

  • dongqianzhan8325 2017-11-07 20:44
    关注

    To configure your server for all anti-spam mechanisms is very difficult and you have to be sure that your SPF record is correct, that your reverse dns configuration is correct and DMARC is also not a wrong decision.

    So in most cases if you don't want to configure all that things it's better to send your mails over SMTP to a bigger mail provider and let them send your Email out.

    Phpmailer con send your mails over SMTP to another provider something like this:

    $phpmailer->IsSMTP(); 
    $phpmailer->SMTPAuth = true; 
    $phpmailer->Host     = "smtprelaypool.ispgateway.de"; 
    $phpmailer->Username = 'mymail@example.com'; 
    $phpmailer->Password = 'MyPassword'; 
    $phpmailer->Port = 25;  
    
    评论

报告相同问题?

悬赏问题

  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver
  • ¥15 图中这种约束条件lingo该怎么表示出来
  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥15 流式socket文件传输答疑
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接