Solved

eMail now being tagged as spam HELP!!!

Posted on 2006-07-22
15
801 Views
Last Modified: 2008-02-07
Hi all

My emails that are sent via a web form are now being tagged as spam to all of my customers that have spam assassin installed on their ISP's servers. I need to resolve this without the use of any modules as I can not add them due to security issues.


FORM CODE:

open (MAIL, "|/bin/sendmail -t") || &DieSafe("Can't open /bin/sendmail!\n");\

print MAIL "From: $AdminsEmail (www.$BusinessesDomain)\n";
print MAIL "Reply-To: $AdminsEmail (www.$BusinessesDomain)\n";
print MAIL "To: $FORM{'Email'} ($FORM{'ContactName'})\n";  
print MAIL "Subject: Copy of your $FormUsedFor to $BusinessesDomain.\n";

print MAIL "\n\nOn $Date you sent the following $FormUsedFor to $BusinessesDomain.\n\n";

print MAIL "Contact: $FORM{'FirstName'} $FORM{'LastName'}\n";
print MAIL "Email: $FORM{'Email'}\n\n";

if($FORM{'Company'}){
print MAIL "Company Name: $FORM{'Company'}\n";
}


if($FORM{'Phone'}){
print MAIL "Phone: $FORM{'Phone'}\n\n";
}

if($FORM{'Hearaboutus'}){
print MAIL "How did you hear about us: $FORM{'Hearaboutus'}\n\n";
}

print MAIL "Message: $FORM{'Message'}\n\n";

print MAIL "\n__________________________________________________\n\n";

print MAIL "$BusinessesName\n";
print MAIL "$BusinessesStreetAddress\n";
print MAIL "$BusinessesTown, $BusinessesState $BusinessesZip\n\n";

print MAIL "Phone: $BusinessesPhone\n";

if($BusinessesFax){
print MAIL "Fax: $BusinessesFax\n";
}

print MAIL "Thank you for visiting www.$BusinessesDomain!\n\n";
close(MAIL);


SPAM SCORING RULES :

Marked as spam if score is over  5.0

0.5 HTML_20_30             BODY: Message is 20% to 30% HTML
0.1 MIME_HTML_ONLY         BODY: Message only has text/html MIME parts
0.0 HTML_MESSAGE           BODY: HTML included in message
0.7 MIME_HTML_NO_CHARSET   RAW: Message text in HTML without charset
3.3 MSGID_FROM_MTA_SHORT   Message-Id was added by a relay
1.9 MIME_HEADER_CTYPE_ONLY 'Content-Type' found without required MIME
0
Comment
Question by:blnukem
  • 7
  • 4
  • 2
  • +2
15 Comments
 
LVL 28

Expert Comment

by:FishMonger
ID: 17160549
Have you tried contacting the ISP's and asking them to add you to their whitelist?
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17161325
Add this line after the subject one:
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: text/plain\n";

That should take care of:
1.9 MIME_HEADER_CTYPE_ONLY 'Content-Type' found without required MIME
0
 
LVL 26

Accepted Solution

by:
DireOrbAnt earned 500 total points
ID: 17161335
Make it:
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: text/plain; charset=\"US-ASCII\"\n";
print MAIL "Content-Transfer-Encoding: 7bit\n";

That should quiet:
0.7 MIME_HTML_NO_CHARSET   RAW: Message text in HTML without charset
1.9 MIME_HEADER_CTYPE_ONLY 'Content-Type' found without required MIME

Now this one:
3.3 MSGID_FROM_MTA_SHORT   Message-Id was added by a relay

Is tricky, maybe add a random one:
print MAIL "Message-ID: <A".int(rand(1000000))."\@$BusinessesDomain)>\n";

0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 8

Expert Comment

by:jhurst
ID: 17163845
This is not a perl issue.  This is an issue that you have been tagged by spamass - you will need to get them to untag you.

Did you spam?

I will tell you that as a matter of practice I send eMails from a variety of domains that are never my real one.  With domain names being as cheap as they are today this is the solution, then when you get tagged you just close that down and start again.  You may also need to move to a different ip but I have rarely found that to be true.

And, NO, I do not send spam!
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17163896
jhurst, SpamAssassin, as with most SPAM engine, uses a set of rules to flag you as SPAM, when you reach a set number of "spam points", you are out.
So this IS a perl issue for blnukem. If he can send out a proper set of Mail headers, the filters will cut him a break.

blnukem, try the extra prints and post here the SPAM result (if any).

Now, you could also ask every ISP in the world (or your client's) to whitelist you... But might will refuse and if you can fix the issue from your side, you don't need to involve anybody else.
0
 
LVL 8

Expert Comment

by:jhurst
ID: 17164689
I do not agree with you Dire.., I think that he is being flagged not because he is not setting the headers but because hs is being seen as triggering some other rule.  I believe that the evidence for this is that he has not changed the headers that he sends and he used to be able to get past the filters and now can not.

Further, I have software that sends out a little over 20million eMails, all double-opt-in, and so have seen this type of thing with SpamAssassin before.

BTW, the root/origin of Assassin is the same as Hashish :)
0
 
LVL 48

Expert Comment

by:Tintin
ID: 17164990
You biggest spamassassin scorer (3.3) is the message-id being added by a mail relay.  I had the same issue with my postcard software, so I changed it to add it's own message ID.

eg:

my $msg_id = int(time).rand().rand() . '@mydomain.com';

print MAIL "Message-ID: $msg_id\n";
0
 
LVL 48

Expert Comment

by:Tintin
ID: 17165025
For those who think this *is* a Perl issue, let's change the script to:


#!/bin/ksh
( print "From: $AdminsEmail (www.$BusinessesDomain)\n";
print "Reply-To: $AdminsEmail (www.$BusinessesDomain)\n";
print "To: $Email ($ContactName)\n";
print "Subject: Copy of your $FormUsedFor to $BusinessesDomain.\n";

print "\n\nOn $Date you sent the following $FormUsedFor to $BusinessesDomain.\n\
n";

print "Contact: $FirstName $LastName\n";
print "Email: $Email\n\n"; ) | /usr/lib/sendmail -t


As you can see, the script is virtually the same as the Perl version.  Does this now turn the problem into a ksh issue?

I'm not trying to be smart or funny here, but one of the most important problem solving skills is to be able to partition the problem, ie: determine which technology is part of the problem.  In this instance, the problem wasn't with Perl but with the email headers being generated.  The generation of email headers is pretty much the same in whatever language you are using (unless you are using a library/module) because all you are essentially doing is a print.

Same applies for Perl scripts that generate dodgy HTML.  It's the HTML that's dodgy, not inherently the Perl script.
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17165193
I never mean't to say that "Perl" was the problem here. Sorry if it was taken that way. Since the program is in Perl, I guess I used it.
So, I meant to say, it's an issue with how the program is written. How is that?

Now, I deal with plenty of email sending myself, maybe not to the extent jhurst does.

So for starters, blnukem is not sending out a proper set of email headers, that's a fact. If this was an issue with one of my script/program, I would first try to see how I could solve it from my side, before involving everyone.

In my post, I proposed adding 4 headers (including Message-ID) to make it (more) compliant..
From the Spam Assasin score (those are facts too), it could remove all of these:
0.7 MIME_HTML_NO_CHARSET   RAW: Message text in HTML without charset
3.3 MSGID_FROM_MTA_SHORT   Message-Id was added by a relay
1.9 MIME_HEADER_CTYPE_ONLY 'Content-Type' found without required MIME

So he would keep these ones:
0.5 HTML_20_30             BODY: Message is 20% to 30% HTML
0.1 MIME_HTML_ONLY         BODY: Message only has text/html MIME parts
0.0 HTML_MESSAGE           BODY: HTML included in message

That would give him a SpamAssassin score of 0.6 and would let the email go to their recipients.

If it works, which I think it will (maybe with a tweak or two), then blnukem will reach his goal, sending emails to customers.
And the effort will be minimal, so I'm not sure what we are all arguing about, if we are ;)
0
 
LVL 48

Expert Comment

by:Tintin
ID: 17165259
Sorry, DireOrbAnt.

Didn't see your post about Message-Id.  I don't think we're arguing, we're just having robust and useful discussions :-)
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17165323
>>>robust and useful discussions
Cool, I'm down! Nice login name.
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17202828
blnukem? Have you tried any of this yet?

We're dangling on a "thread" here, Tintin is just about to pass out!

Please let us know if you resolved your issue.

DOA
0
 

Author Comment

by:blnukem
ID: 17240707
Sorry about the delay I was away anyway here is what I did:

my $MSG_ID = int(time).rand().rand() . "\@$BusinessesDomain";

open (MAIL, "|/bin/sendmail -t") || &DieSafe("Can't open /bin/sendmail!\n");\

print MAIL "From: $AdminsEmail (www.$BusinessesDomain)\n";
print MAIL "Reply-To: $AdminsEmail (www.$BusinessesDomain)\n";
print MAIL "To: $FORM{'Email'} ($FORM{'ContactName'})\n";  
print MAIL "Subject: Copy of your $FormUsedFor to $BusinessesDomain.\n";

print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: text/plain; charset=\"US-ASCII\"\n";
print MAIL "Content-Transfer-Encoding: 7bit\n";
print MAIL "Message-ID: $MSG_ID\n";
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17242059
Not flagged as spam anymore? Can you output the resulting SpamAssassin headers (if any) so we/you can see if there is more improvements to be done?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 17245648
The order of the headers is important.  You should use

print MAIL <<EOF;
From: $AdminsEmail (www.$BusinessesDomain)
Reply-To: $AdminsEmail (www.$BusinessesDomain)
To: $FORM{'Email'} ($FORM{'ContactName'})
MIME-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
Message-ID: $MSG_ID
Subject: Copy of your $FormUsedFor to $BusinessesDomain.

On $Date you sent the following $FormUsedFor to $BusinessesDomain.

Contact: $FORM{'FirstName'} $FORM{'LastName'}
Email: $FORM{'Email'}

EOF
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
cpan issue 1 63
pattern matching in perl 2 103
work on ods spreadsheet with perl in ubuntu 4 76
Check file date before getting folder path 1 72
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now