PHP邮件:所有邮件都在SPAM文件夹中收到 [英] PHP mail: All emails are received in the SPAM folder

查看:187
本文介绍了PHP邮件:所有邮件都在SPAM文件夹中收到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个简单的PHP邮件发件人,以一次将图像发送到多个地址。不知道为什么,但电子邮件不断到达SPAM文件夹,无论我发送什么邮件管理器...

I'm making a simple PHP mail sender to send an image to multiple addresses at a time. Don't know why, but the emails keep on arriving at the SPAM folder, no matter what email manager I send them...

这是我如何调用PHP邮件发件人文件:

Here's how I call the PHP mail sender file:

$.ajax({ url: 'mail_sender.php?receiver=' + receiver + '&=lang' + lang,

    success: function (response)
    {
        console.log('Mails ' + response);
    }
});

这是我的PHP文件结构:

And this is my PHP file structure:

<?php

// Reciever
$_to           = $_GET["receiver"];
$_lang      = $_GET["lang"];

// subject
$subject        = 'My Subject';

// sender
$sender         = "sender@sender.es";

// message
$message        = '
                <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
                <head>
                <META name="generator" content="HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org">
                <TITLE></TITLE>
                <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
                </head>
                <body>
                  <img src='."https://www.mysite.es/demo/img/emails/imagen_".$_lang.".jpg".' />
                </body>
                </html>
';

// To send HTML mail, the Content-type header must be set
$headers  = "Reply-To: <sender@sender.es> \r\n";
$headers .= "Return-Path: <sender@sender.es>" . "\r\n";
$headers .= "From: <sender@sender.es>" . "\r\n"; 
$headers .= "Organization: My organization" . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=utf-8" . "\r\n";
$headers .= "X-Priority: 3" . "\r\n";
$headers .= "X-Mailer: PHP/". phpversion();

// Mail it
$ret = mail($_to, $subject, $message, $headers);

if ( $ret == '' || $ret )
{
    echo $ret;
}else{
    echo $ret;
}

?>

任何人都可以提供一些线索?

Can anyone give some clues?

非常感谢!

推荐答案

尝试发送纯文本电子邮件而不是HTML(如果符合您的需要)。根据我的经验,HTML经常触发垃圾邮件过滤器,但是您真的需要使用HTML尝试查看mailchimp使用的一些电子邮件模板。

Try sending a plain text email instead of HTML (if that suits your needs). In my experience the HTML often triggers spam filters but f you really need to use HTML try to look at some of the email templates that mailchimp uses.

https://github.com/mailchimp/Email-Blueprints

这篇关于PHP邮件:所有邮件都在SPAM文件夹中收到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆