Restricted Notes by a Geek

Mail

How to add Baracuda RBL and Passive Spam Blocklist to Spamassassin

by Tinuva on Jan.30, 2009, under Mail

I recently added the BRBL and PSBL lists to our spamassassin configuration to help block more spam. As a test we first added it to only make a score difference of 1.0 so that we can see how effective it would be without having too many false positives.

Add the following code to /etc/mail/spamassassin/local.cf to activate the these:

### Custom RBL
# URL: http://psbl.surriel.com/
header RCVD_IN_PSBL eval:check_rbl(’psbl’, ‘psbl.surriel.com.’)
describe RCVD_IN_PSBL Received via a relay in PSBL (Passive Spam Block List)
tflags RCVD_IN_PSBL net
score RCVD_IN_PSBL 1.0

# URL: http://www.barracudacentral.org/rbl/
header __RCVD_IN_BRBL eval:check_rbl(’brbl’, ‘b.barracudacentral.org’)
describe __RCVD_IN_BRBL received via a relay in b.barracudacentral.org
header RCVD_IN_BRBL_RELAY eval:check_rbl_sub(’brbl’, ‘127.0.0.2′)
tflags RCVD_IN_BRBL_RELAY net
describe RCVD_IN_BRBL_RELAY received via a relay rated as poor by Barracuda
score RCVD_IN_BRBL_RELAY 1.0

You should see an example as follow:

X-Spam-Report:
* 1.0 RCVD_IN_BRBL_RELAY RBL: received via a relay rated as poor by * Barracuda * [83.35.208.195 listed in b.barracudacentral.org

3 Comments more...

Courier-Imap : Imap email box inaccessible

by Tinuva on Jan.09, 2009, under Linux, Mail, Plesk

Had a client bugging me that his email inbox is not working via IMAP from anywhere in the world whilst none of the other clients on the same server had any problems at all whatsoever.

It turns out there was a courier.lock file in his inbox’s tmp folder. After removing this file he was able to access his mails again with no lost mails.

Specific folder for this in my case on a plesk server was: /var/qmail/mailnames/domainname.co.za/username/Maildir/tmp

Leave a Comment more...

Sending email that is acceptable by Spamassassin

by Tinuva on Sep.25, 2008, under Development, Mail

I find this happening a lot. Nowadays many users or small business’s or even small isps will make use of Spamassassin to help control the influx of spam received on a daily basis. As someone working in the hosting environment I see multiple clients asking why their webmail forms are not received, in which case these mails usually get blocked as spam for many reasons it is not spam.

So I have put together a sample php script making use of the built in Mail() function to send mail which is 100% accepted by most spamassassin installations as long as you don’t add actual spam content on which they will still block emails.

The script:

// To email address
$email = "myEmailAddress@domain.coma";
$email_name = "myName mySurname";

// From email address
$from = "admin@mydomain.com";
$from_name = "Website Email Form";

// The message
$subject = "My Website Form";
$message = "Someone submitted the following information from our online form.
First Name: ".$_POST["firstName"]."
Favorite food: ".$_POST["favoritefood"]."
";
$message_html = "

Someone submitted the following information from our online form.

First Name: “.$_POST["firstName"].”

Favorite food: “.$_POST["favoritefood"].”


“;

/***********************************************/
/* No need to modify anything down here */
/* Note that these are needed to send the mail */
/***********************************************/
// Generate text + html version
$random_hash = md5(date(’r', time()));

$mailmessage = ”
–PHP-alt-”.$random_hash.”
Content-Type: text/plain; charset=\”iso-8859-1\”
Content-Transfer-Encoding: 7bit

$message

–PHP-alt-”.$random_hash.”
Content-Type: text/html; charset=\”iso-8859-1\”
Content-Transfer-Encoding: 7bit

$message_html

–PHP-alt-”.$random_hash.”–
“;

// Headers
// To send HTML mail, the Content-type header must be set
$headers = “From: “.$from_name.” <".$from.">” . “\r\n”;
$headers .= “Reply-To: “.$from_name.” <".$from.">” . “\r\n”;
$headers .= “Date: “.date(”r”) . “\r\n”;

// Additional headers
$headers .= “MIME-Version: 1.0″ . “\r\n”;
$headers .= “Content-Type: multipart/alternative; boundary=\”PHP-alt-”.$random_hash.”\”\r\n”;
$headers .= “Message-Id: <".md5(uniqid(microtime()))."@".$_SERVER["SERVER_NAME"].">\r\n”;

// Send the mail
mail($email, $subject, $mailmessage, $headers);

echo “Email sent.”;
?>

The result on different versions of spamassassin with different setups:

Version 3.1.0
X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,HTML_40_50, HTML_MESSAGE,HTML_SHORT_LENGTH autolearn=no version=3.1.0

Version 3.2.5
X-Spam-Status: No, score=-2.598 tag=-999 tag2=5 kill=5 tests=[BAYES_00=-2.599, HTML_MESSAGE=0.001]

So what did I look out for?

- Subject is not in capital letters only
- I send the mail in BOTH text and html format - if only in html a score gets added, text always pass better
- I use a proper from/to/reply-to email domain
- I made sure all the needed headers are attached
- When I use html I also make sure to add the tags

I hope this also help someone else out there.

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...