php mail() 防止垃圾邮件 How to Avoid Spam Filters with PHP mail() Emails

4 ways to make your PHP mail () Less Spammy Emails

 

1. Use Headers

 

In the simple example above, the name and email address was added as the fourth parameter. Instead, consider using headers to set the From and Reply-To email addresses.

<? 
$headers .= "Reply-To: The Sender <sender@sender.com>\r\n"; 
$headers .= "Return-Path: The Sender <sender@sender.com>\r\n"; 
$headers .= "From: The Sender <senter@sender.com>\r\n"; 
?>

 

But headlines are good for more than just set the details on the sender. Also important to set the content type, priority mail, and more. Here are how some additional headers look.

<? 
$headers .= "Organization: Sender Organization\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n" 
?>

 

Be sure to replace the fourth parameter of the variable $ headers as shown below.

<? 
mail("recipient@recipient.com", "Message", "A simple message.", $headers); 
?>

 

完整版:

ini_set('SMTP','mail.domain.com');  
ini_set('smtp_port',465);  
ini_set('sendmail_from',"Your Name <your@email>");  
 
$from      = "Your Name <your@email>";
$to          = "toemail@gmail.com";  
$subject   = "Test";  
$message = "<h1>Test</h1> i want to send  emails !";  

$headers .= "Reply-To: ".$from."\r\n";
$headers .= "Return-Path: ".$from."\r\n";
$headers .= "From: ".$from."\r\n";

$headers .= "Organization: Your Organization\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type:text/html;charset=utf-8\r\n"; 
$headers .= "X-Priority: 1\r\n";
$headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";

mail($to, $subject, $message, $headers); 

 

2. Message sender domain and server domain must match


Spammers send email from a server and the recipient to believe that it came from somewhere else are notorious for. So if you are sending an email to example@example.com, it is a good idea to keep at example.com script.

 

3. Be sure to use the content-type attribute


The content-type attribute allows a sender of the message to say whether or not an email is plain text or HTML, or have attachments. Obviously, the easiest to use the content type is text / plain. You simply add the text as shown in the example simple, and that's it. However, when using content types, additional parts you would expect. For example, with the content type text / html, HTML body tag is expected. Not having this label may result in an email being marked as spam.

 

4. Verify that your server is not blacklisted


When a server is blacklisted, which means that the server has been identified as one who has been sending a lot of spam. This results in the recipient's mail servers reject or filter all mail that is received from that server. So if your mail is received is not a good idea to check that the server has been blacklisted. This goes for both shared and dedicated servers. In a shared environment, it is common for other users on the server to send spam. And in a dedicated environment, spammers may have found a way to exploit a vulnerability in a server or a contact form to send spam. Making it easy for any type of server blacklisted.

Well, now that you have the basics on how to avoid spam filters, rebuild scripts and email happy!

 

from:  http://blog.infotwistsolutions.com/2013/02/how-to-avoid-spam-filters-with-php-mail.html

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
贝叶斯算法是一种常用的机器学习算法,可以用于实现垃圾邮件分类数据集emails的分类任务。 首先,我们需要将垃圾邮件分类数据集emails进行预处理。这包括去除邮件中的特殊字符、停用词和数字,以及进行词干提取。然后,我们将每封邮件表示为一个向量,其中每个元素表示一个特定的单词,该单词在邮件中出现的频率或存在与否。 接着,根据贝叶斯算法的原理,我们需要计算垃圾邮件和非垃圾邮件的概率。我们可以通过计算训练集中垃圾邮件和非垃圾邮件的频率来得到这些概率。 然后,我们需要计算给定某个单词的条件概率。这个条件概率表示了在一个邮件被分类为垃圾邮件或非垃圾邮件的情况下,该单词出现的概率。我们可以通过计算训练集中垃圾邮件中该单词出现的概率和非垃圾邮件中该单词出现的概率,再加上一个平滑项来计算这个条件概率。 最后,我们可以使用贝叶斯算法进行预测。对于一个待分类的邮件,我们可以计算出该邮件属于垃圾邮件和非垃圾邮件的概率。根据贝叶斯定理,我们可以将这个待分类邮件归为具有最高概率的那个类别。 通过使用贝叶斯算法实现垃圾邮件分类数据集emails,我们可以高效地将邮件进行分类,并根据分类结果采取不同的处理方式,提高用户过滤垃圾邮件的能力。同时,我们还可以不断优化算法参数和模型结构,以提高分类准确率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值