我有一个大量的用户列表,这些用户在注册时没有启用任何垃圾邮件过滤器。
我想区分哪些注册用户很可能是垃圾邮件发送者。我试图使用Akismet来实现这一点,但到目前为止,Akismet告诉我所有用户都不是垃圾邮件发送者。这可能是因为Akismet真正用于评论,而在注册期间评论是不可用的。
我向Akismet发送的内容包括用户名、电子邮件地址。对于URL,我使用电子邮件域名。对于他们的评论,我使用以下格式:"Hi, I'm $username from $domain registered on $date with email $email and website $url"。
然而,就像我说的那样,即使用户看起来像是垃圾邮件发送者,这种方法总是返回有效的用户。
如果您对完整代码感兴趣:
<?php
// bring php process to this dir
chdir(dirname(__FILE__));
// include Joomla Framework
require('../bootstrap-joomla.php');
// akismet class
require('akismet.class.php');
/**
* Retrieves users not yet validated
*/
function getUsers($userid, $limit = 10) {
global $database;
$database->setQuery("SELECT * FROM jos_users WHERE akismet_validated = 0 LIMIT " . intval($limit));
$Users = $database->loadObjectList();
return $Users;
}
/**
* sets the validation results for the user
*/
function saveValidationResult($userid, $spammer) {
global $database;
$database->setQuery("UPDATE jos_users set akismet_validated = 1, akismet_spammer = " . intval($spammer) . " WHERE id = " . $userid . " LIMIT 1");
return $database->query();
}
// get non validated users
$Users = getUsers();
// validate each user
foreach($Users as $User) {
list($user, $domain) = explode('@', $User->email);
$name = $User->username;
$email = $User->email;
$url = $domain;
$comment = "Hello, I am $name, registered on $User->registerDate from <a href=\"$url\">$url</a>.\r\n";
$akismet = new Akismet('http://www.fijiwebdesign.com/', 'c511157d1d98');
$akismet->setCommentAuthor($name);
$akismet->setCommentAuthorEmail($email);
$akismet->setCommentAuthorURL($url);
$akismet->setCommentContent($comment);
//$akismet->setPermalink('http://www.fijiwebddesign.com/');
echo "$User->id, $User->username : ";
if($akismet->isCommentSpam()) {
saveValidationResult($User->id, true);
echo "Spammer";
} else {
saveValidationResult($User->id, false);
echo "Not Spammer";
}
echo "\r\n";
}