Benoit Panizzon | 2 May 2013 11:27
Picon
Favicon

How to change envelope sender?

Yo

Goal: Minimize Backscatter.

Problem: Customers do forward their email address to some other addresses 
which are have full quota or just any other problems.

Solution:
Do this whole Aliasing and Forward-Address handling with MIMEDefang. As the 
local email address doing the forward is know to be good (or not, but then we 
don't accept the email so won't create any backscatter) we know we can drop 
further errors happening while forwarding there.

In filter_recipient we check if the recipient is being forwarded to some other 
Destination. We can md_check_against_smtp_server to see if the recipient 
exists. But we don't know yet if the quota is full or similar. We only know 
this wen we queued and sent the actual email, but then we need to generate a 
bounce if this fails.
So let's change the sender to the address of the address of the local 
recipient who wants to have his emails forwarded somewhere else. So he get's 
the blame/bounce if his forward does not work.

Now I miss some kind of command to do that within MIMEDefang. $sender is read 
only I assume.

The complicated way would be to re-send / discard the email. Is there another 
solution?
This could also be used to implement propper SRS (which we actualy don't need 
anymore if we use the forwarder's address as sender).

(Continue reading)

Philip Prindeville | 30 Apr 2013 19:39

Constructing MIME::Entity via new

I'm not quite getting something in the MIME::Entity documentation.  It says:

PUBLIC INTERFACE
   Construction
       new [SOURCE]
           Class method.  Create a new, empty MIME entity.  Basically, this
           uses the Mail::Internet constructor...

           If SOURCE is an ARRAYREF, it is assumed to be an array of lines
           that will be used to create both the header and an in-core body.

           Else, if SOURCE is defined, it is assumed to be a filehandle from
           which the header and in-core body is to be read.

           Note: in either case, the body will not be parsed: merely read!

but when I try:

my $pop = Net::POP3->new('localhost', Port => 8110, Timeout => 15, Debug => $debug);

...

for (my $i = 1; $i <= $msgs; ++$i) {
  my $lines = $pop->top($i, 0);

  my $msg = MIME::Entity->new($lines);				<< line 38

  print $msg->as_string();
}

(Continue reading)

tim | 20 Apr 2013 18:50

rps-mail-eventreporter installation

I am not a linux expert of perl expert.

I have sendmail, amavis, and clamav working on a new opensuse 12.3 load.

I'm trying to get mimedefang and spamassassin working.

I downloaded the files shown at the mimedefang site.

When doing a "perl Makefile.PL" command (as root user) for the
rps-mail-eventreporter I get an error message of:

Bareword "auto_install" not allowed while "strict subs" in use at Makefile.PL line 17.
Execution of Makefile.PL aborted due to compilation errors.

I've searched the mailing list archives and couldn't find anything.

I'm sure this is a simple problem to fix but I can't find anything on
the internet about it.

Help!

Benoit Panizzon | 16 Apr 2013 11:51
Picon
Favicon

How to count recipients in filter_recipient

Hello

The situation:

Recipients have different SpamAssassin Settings:

Recipeint A => "NO FILTERING";
Recipient B => "REJECT SPAM";

Now an email arrives
mail from:<sender>
rcpt to:<Recipient A>
rcpt to:<Recipient B>

Now if this is an email that will be handled as spam, we have the problem, 
that Recipeint A does want to receive that email and Recipient B want us to 
reject it during SMTP Handshake.

We could:
Accept the Email and deliver it only to Recipient A.

Problem: If it was a false positive, that sender does not know it was not 
delivered to Recipient B. His Maillog will tell him it was successfully 
delivered. => NoGo.

We could:
Reject that email: Recipient A will complain that we filtered the email even 
though his settings tell us not to do so. = NoGo.

Solution:
(Continue reading)

Lars Sorensen | 15 Apr 2013 14:18

Errors Warnings multiplexor Starting slave

I recently upgraded both my Perl version and Mimedefang and are seeing some of my mimedefang.pl processes hanging.
Most likely part of a poorly written filter on my part and I'm hunting that down.

But after the upgrade I see these log entries:

Apr 15 07:06:58 gw1 mimedefang-multiplexor[13280]: Starting slave 4 (pid 13530) (5 running): About to
perform scan
Apr 15 07:06:59 gw1 mimedefang-multiplexor[13280]: r3FC6uX8013525: Slave 4 stderr:
main::rebuild_entity() called too early to check prototype at /usr/bin/mimedefang.pl line 805.
Apr 15 07:06:59 gw1 mimedefang-multiplexor[13280]: r3FC6uX8013525: Slave 4 stderr: defined( <at> array)
is deprecated at /usr/bin/mimedefang.pl line 7087.
Apr 15 07:06:59 gw1 mimedefang-multiplexor[13280]: r3FC6uX8013525: Slave 4 stderr: 	(Maybe you should
just omit the defined()?)
Apr 15 07:06:59 gw1 mimedefang-multiplexor[13280]: r3FC6uX8013525: Slave 4 stderr: defined( <at> array)
is deprecated at /usr/bin/mimedefang.pl line 7125.
Apr 15 07:06:59 gw1 mimedefang-multiplexor[13280]: r3FC6uX8013525: Slave 4 stderr: 	(Maybe you should
just omit the defined()?)

Anybody seen these?

Running:
RHEL 5
Perl 5.16.3
mimedefang version 2.73

Best regards
Lars Sorensen
Lars Sorensen | 2 Apr 2013 11:30

Problem matching occurrences other than first line in email.

Hello,

Trying to get heads and tails of Mimedefang and Perl, I'm stuck understanding why the below code in
Mimedefang will only match on the first line of an email and ignore the rest.

So:
"open something anotherthing thirdthing" only matches if on the first line of the email, and additional
lines are ignored.
I'm trying to match all occurrences of lines with this pattern and add headers accordingly.
Can anybody throw me a bone on this one?

###########################################################################
sub filter {
	my($entity) =  <at> _;
	
	if (grep {/email\ <at> example\.com/i}  <at> Recipients) {
		my $io;
		if ($io = $entity->open("r")) {
			while (defined($_ = $io->getline)) {
				if  ( $_ =~ /\bopen\W+([a-z]+)(\W+)?([a-z]+)?(\W+)?([a-z]+)?/i) {
					action_add_header('X-header',"$1, $3, $5");
					last;   
				}
			}
        	$io->close;
        	}
	}
}
###########################################################################

(Continue reading)

Richard Laager | 27 Mar 2013 09:41
Favicon
Gravatar

md_check_against_smtp_server() returned an empty response

This is unrelated to the other thread.

I'm troubleshooting an issue where md_check_against_smtp_server()
intermittently hangs for 5 minutes. It's *always* 300 seconds exactly
(ignoring sub-second precision).

The error is always the "returned an empty response" from
get_smtp_return_code().

I'm using this function for doing callbacks against the sender's
address. I look up the MX records using Net::DNS. Before you hate me too
much, I cache positive responses for 7 days and negative responses for 1
hour. The delays discussed above are around the actual
md_check_against_smtp_server() call and *nothing else*. To get this far,
I had to instrument my filter with logging before and after every
non-trivial block of code.

Does anyone have any idea why the 15 second IO::Socket::INET timeout
isn't applying in these cases?

Thanks,
Richard
This is unrelated to the other thread.

I'm troubleshooting an issue where md_check_against_smtp_server()
intermittently hangs for 5 minutes. It's *always* 300 seconds exactly
(ignoring sub-second precision).

(Continue reading)

kd6lvw | 27 Mar 2013 03:01
Picon
Favicon

SPF Check - was Re: md_check_against_smtp_server and md_graphdefang_log

--- On Tue, 3/26/13, James Curtis <jameswcurtis <at> hotmail.com> wrote:
> Thaks for all the info, the pros and cons.  Most of them I knew, I'll
> probably be looking for info on how to get MIMEDefang to work with SPF
> later.  

Here's what I use:

use Mail::SPF;

sub filter_sender {
    my ($sender, $ip, $hostname, $helo) =  <at> _;
    if ($sender =~ / <at> ([^>]+)/) {
        my $domain = $1;
        my  <at> bogushosts = md_get_bogus_mx_hosts($domain);
        my $i = scalar( <at> bogushosts);
        return('REJECT',"Domain $domain has $i bogus MX record" .
            (($i < 2)? '' : 's') .': '. join(' ', <at> bogushosts),'550','5.4.4')
            if ($i);
    } else {
        $sender = "<postmaster\ <at> $helo>" unless ($sender =~ /[^<>]+/);
    }
    return('CONTINUE',"OK - Localhost [$ip]",'250','2.4.0')
        if ($ip =~ /^(::1|127\.0\.0\.1|UNKNOWN)$/i);
    read_commands_file();
    my $id = ($sender =~ /<(.+)>/) ? $1 : $sender;
    my $spfserver = Mail::SPF::Server->new(max_void_dns_lookups => undef,
        hostname => $SendmailMacros{'if_name'} );
    my $spfrequest = Mail::SPF::Request->new(versions => [1], scope => 'mfrom',
        identity => $id, ip_address => $ip, helo_identity => $helo);
    my $r = $spfserver->process($spfrequest);
(Continue reading)

Richard Laager | 26 Mar 2013 01:22
Favicon
Gravatar

Re: md_check_against_smtp_server and md_graphdefang_log

On Mon, 2013-03-25 at 17:00 -0700, kd6lvw <at> yahoo.com wrote:
> This is what I saw:
> >  if ($retval ne 'CONTINUE') {
> >  $sock->print("QUIT\r\n");
> 
> Looks pretty conditional to me.  If the return value is the continue literal, no quit is issued.

I've now pulled mimedefang.pl.in from the 2.73 tarball off the website.
Here's the function from HELO onwards:

    $sock->print("HELO $helo\r\n");
    $sock->flush();

    ($retval, $code, $dsn, $text) = get_smtp_return_code($sock, $recip, $server);
    if ($retval ne 'CONTINUE') {
	$sock->print("QUIT\r\n");
	$sock->flush();
	# Swallow return value
	get_smtp_return_code($sock, $recip, $server);
	$sock->close();
	return ($retval, $text, $code, $dsn);
    }

    $sock->print("MAIL FROM:$sender\r\n");
    $sock->flush();

    ($retval, $code, $dsn, $text) = get_smtp_return_code($sock, $recip, $server);
    if ($retval ne 'CONTINUE') {
	$sock->print("QUIT\r\n");
	$sock->flush();
(Continue reading)

James Curtis | 25 Mar 2013 18:30
Picon
Favicon

Re: md_check_against_smtp_server and md_graphdefang_log

> > I guess I need a mimedefang-filter and Perl for dummies book.
> 
> There are plenty of pretty good "Intro to Perl" books; check the O'Reilly
> site. As for intro to MIMEDefang, you could have a look at slides from a
> talk I gave (a long time ago):
> 
> http://www.mimedefang.org/static/mimedefang-lisa04.pdf
I read through that before going to the list. Page 86 seems to be the relevant page, but without sample code in
context I'm still lost. 
I did read through the mimedefang.pl file enough to find: 
#***********************************************************************
# %PROCEDURE: md_check_against_smtp_server
# %ARGUMENTS:
# sender -- sender e-mail address
# recip -- recipient e-mail address
# helo -- string to put in "HELO" command
# server -- SMTP server to try.
# port -- optional: Port to connect on (defaults to 25)
# %RETURNS:
# ('CONTINUE', "OK") if recipient is OK
# ('TEMPFAIL', "err") if temporary failure
# ('REJECT', "err") if recipient is not OK.
# %DESCRIPTION:
# Verifies a recipient against another SMTP server by issuing a
# HELO / MAIL FROM: / RCPT TO: / QUIT sequence
#***********************************************************************
AND this
($retval, $code, $dsn, $text) = get_smtp_return_code($sock, $recip, $server);
 if ($retval ne 'CONTINUE') {
 $sock->print("QUIT\r\n");
(Continue reading)

Ben Kamen | 25 Mar 2013 04:42
Favicon

Slightly OT: SpamAssassin freemail check data

Hey all,

  Where does the freemail filters for SA get it's list of email addy's?

I'm looking at the FreeMail.pm -- and I'm not perl coherent enough to have it jump out at me.

I'm just wondering if it's downloaded and/or also comes from a locally scanned db (through sa "learn")..

Thanks,

  -Ben

--

-- 
Ben Kamen - O.D.T., S.P.
----------------------------------------------------------------------
eMail: ben <at> benjammin.net                      http://www.benjammin.net
Fortune says:
Romulan women are not like Vulcan females.  We are not dedicated to
pure logic and the sterility of non-emotion.
		-- Romulan Commander, "The Enterprise Incident",
		   stardate 5027.3
-                                                              -
NOTICE: All legal disclaimers sent to benjammin.net/benkamen.net
or any of it's affiliated domains are rendered null and void on
receipt of communications and will be handled/considered as such.


Gmane