2002-09-24 12:56:35 +02:00
|
|
|
package Qpsmtpd::SMTP;
|
|
|
|
use Qpsmtpd;
|
|
|
|
@ISA = qw(Qpsmtpd);
|
|
|
|
|
|
|
|
package Qpsmtpd::SMTP;
|
|
|
|
use strict;
|
|
|
|
use Carp;
|
|
|
|
|
|
|
|
use Qpsmtpd::Connection;
|
|
|
|
use Qpsmtpd::Transaction;
|
|
|
|
use Qpsmtpd::Plugin;
|
|
|
|
use Qpsmtpd::Constants;
|
2004-06-29 23:45:35 +02:00
|
|
|
use Qpsmtpd::Auth;
|
2004-07-15 01:58:47 +02:00
|
|
|
use Qpsmtpd::Address ();
|
2002-09-24 12:56:35 +02:00
|
|
|
|
|
|
|
use Mail::Header ();
|
2003-09-15 12:50:27 +02:00
|
|
|
#use Data::Dumper;
|
2002-09-24 12:56:35 +02:00
|
|
|
use POSIX qw(strftime);
|
|
|
|
use Net::DNS;
|
|
|
|
|
2004-11-27 07:38:32 +01:00
|
|
|
# this is only good for forkserver
|
|
|
|
# can't set these here, cause forkserver resets them
|
|
|
|
#$SIG{ALRM} = sub { respond(421, "Game over pal, game over. You got a timeout; I just can't wait that long..."); exit };
|
|
|
|
#$SIG{ALRM} = sub { warn "Connection Timed Out\n"; exit; };
|
2002-09-24 12:56:35 +02:00
|
|
|
|
|
|
|
sub new {
|
|
|
|
my $proto = shift;
|
|
|
|
my $class = ref($proto) || $proto;
|
|
|
|
|
|
|
|
my %args = @_;
|
|
|
|
|
|
|
|
my $self = bless ({ args => \%args }, $class);
|
|
|
|
|
|
|
|
my (@commands) = qw(ehlo helo rset mail rcpt data help vrfy noop quit);
|
|
|
|
my (%commands); @commands{@commands} = ('') x @commands;
|
|
|
|
# this list of valid commands should probably be a method or a set of methods
|
|
|
|
$self->{_commands} = \%commands;
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
|
2002-09-24 12:56:35 +02:00
|
|
|
$self;
|
|
|
|
}
|
|
|
|
|
2003-04-21 11:42:01 +02:00
|
|
|
sub command_counter {
|
|
|
|
my $self = shift;
|
|
|
|
$self->{_counter} || 0;
|
|
|
|
}
|
2002-09-24 12:56:35 +02:00
|
|
|
|
|
|
|
sub dispatch {
|
|
|
|
my $self = shift;
|
|
|
|
my ($cmd) = lc shift;
|
|
|
|
|
2003-04-21 11:42:01 +02:00
|
|
|
$self->{_counter}++;
|
|
|
|
|
2002-09-24 12:56:35 +02:00
|
|
|
#$self->respond(553, $state{dnsbl_blocked}), return 1
|
|
|
|
# if $state{dnsbl_blocked} and ($cmd eq "rcpt");
|
|
|
|
|
2003-04-15 19:39:03 +02:00
|
|
|
if ($cmd !~ /^(\w{1,12})$/ or !exists $self->{_commands}->{$1}) {
|
|
|
|
my ($rc, $msg) = $self->run_hooks("unrecognized_command", $cmd);
|
|
|
|
if ($rc == DENY) {
|
|
|
|
$self->respond(521, $msg);
|
|
|
|
$self->disconnect;
|
|
|
|
}
|
|
|
|
elsif ($rc == DONE) {
|
|
|
|
1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->respond(500, "Unrecognized command");
|
|
|
|
}
|
|
|
|
return 1
|
|
|
|
}
|
2002-09-24 12:56:35 +02:00
|
|
|
$cmd = $1;
|
|
|
|
|
|
|
|
if (1 or $self->{_commands}->{$cmd} and $self->can($cmd)) {
|
|
|
|
my ($result) = eval { $self->$cmd(@_) };
|
2004-03-05 13:46:24 +01:00
|
|
|
$self->log(LOGERROR, "XX: $@") if $@;
|
2002-09-24 12:56:35 +02:00
|
|
|
return $result if defined $result;
|
|
|
|
return $self->fault("command '$cmd' failed unexpectedly");
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fault {
|
|
|
|
my $self = shift;
|
|
|
|
my ($msg) = shift || "program fault - command not performed";
|
|
|
|
print STDERR "$0[$$]: $msg ($!)\n";
|
|
|
|
return $self->respond(451, "Internal error - try again later - " . $msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub start_conversation {
|
|
|
|
my $self = shift;
|
|
|
|
# this should maybe be called something else than "connect", see
|
|
|
|
# lib/Qpsmtpd/TcpServer.pm for more confusion.
|
|
|
|
my ($rc, $msg) = $self->run_hooks("connect");
|
2003-04-15 19:01:43 +02:00
|
|
|
if ($rc == DENY) {
|
|
|
|
$self->respond(550, ($msg || 'Connection from you denied, bye bye.'));
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
elsif ($rc == DENYSOFT) {
|
|
|
|
$self->respond(450, ($msg || 'Connection from you temporarily denied, bye bye.'));
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
elsif ($rc == DONE) {
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
elsif ($rc != DONE) {
|
2002-09-24 12:56:35 +02:00
|
|
|
$self->respond(220, $self->config('me') ." ESMTP qpsmtpd "
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
. $self->version ." ready; send us your mail, but not your spam.");
|
2003-04-15 19:01:43 +02:00
|
|
|
return DONE;
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub transaction {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->{_transaction} || $self->reset_transaction();
|
|
|
|
}
|
|
|
|
|
|
|
|
sub reset_transaction {
|
|
|
|
my $self = shift;
|
2003-12-03 09:07:36 +01:00
|
|
|
$self->run_hooks("reset_transaction") if $self->{_transaction};
|
2004-09-23 15:51:09 +02:00
|
|
|
return $self->{_transaction} = Qpsmtpd::Transaction->new();
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub connection {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->{_connection} || ($self->{_connection} = Qpsmtpd::Connection->new());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub helo {
|
|
|
|
my ($self, $hello_host, @stuff) = @_;
|
|
|
|
my $conn = $self->connection;
|
|
|
|
return $self->respond (503, "but you already said HELO ...") if $conn->hello;
|
|
|
|
|
2004-09-01 07:56:52 +02:00
|
|
|
my ($rc, $msg) = $self->run_hooks("helo", $hello_host, @stuff);
|
2003-03-18 10:43:22 +01:00
|
|
|
if ($rc == DONE) {
|
|
|
|
# do nothing
|
|
|
|
} elsif ($rc == DENY) {
|
|
|
|
$self->respond(550, $msg);
|
|
|
|
} elsif ($rc == DENYSOFT) {
|
|
|
|
$self->respond(450, $msg);
|
|
|
|
} else {
|
|
|
|
$conn->hello("helo");
|
|
|
|
$conn->hello_host($hello_host);
|
|
|
|
$self->transaction;
|
|
|
|
$self->respond(250, $self->config('me') ." Hi " . $conn->remote_info . " [" . $conn->remote_ip ."]; I am so happy to meet you.");
|
|
|
|
}
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub ehlo {
|
|
|
|
my ($self, $hello_host, @stuff) = @_;
|
|
|
|
my $conn = $self->connection;
|
|
|
|
return $self->respond (503, "but you already said HELO ...") if $conn->hello;
|
|
|
|
|
2004-09-01 07:56:52 +02:00
|
|
|
my ($rc, $msg) = $self->run_hooks("ehlo", $hello_host, @stuff);
|
2003-03-18 10:43:22 +01:00
|
|
|
if ($rc == DONE) {
|
|
|
|
# do nothing
|
|
|
|
} elsif ($rc == DENY) {
|
|
|
|
$self->respond(550, $msg);
|
|
|
|
} elsif ($rc == DENYSOFT) {
|
|
|
|
$self->respond(450, $msg);
|
|
|
|
} else {
|
|
|
|
$conn->hello("ehlo");
|
|
|
|
$conn->hello_host($hello_host);
|
|
|
|
$self->transaction;
|
|
|
|
|
2003-04-21 11:42:01 +02:00
|
|
|
my @capabilities = $self->transaction->notes('capabilities')
|
|
|
|
? @{ $self->transaction->notes('capabilities') }
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
: ();
|
2003-04-21 11:42:01 +02:00
|
|
|
|
2004-06-29 23:45:35 +02:00
|
|
|
# Check for possible AUTH mechanisms
|
|
|
|
my %auth_mechanisms;
|
2004-08-31 03:58:57 +02:00
|
|
|
HOOK: foreach my $hook ( keys %{$self->{hooks}} ) {
|
2004-06-29 23:45:35 +02:00
|
|
|
if ( $hook =~ m/^auth-?(.+)?$/ ) {
|
|
|
|
if ( defined $1 ) {
|
|
|
|
$auth_mechanisms{uc($1)} = 1;
|
|
|
|
}
|
|
|
|
else { # at least one polymorphous auth provider
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
%auth_mechanisms = map {$_,1} qw(PLAIN CRAM-MD5 LOGIN);
|
2004-06-29 23:45:35 +02:00
|
|
|
last HOOK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( %auth_mechanisms ) {
|
|
|
|
push @capabilities, 'AUTH '.join(" ",keys(%auth_mechanisms));
|
|
|
|
$self->{_commands}->{'auth'} = "";
|
|
|
|
}
|
|
|
|
|
2003-03-18 10:43:22 +01:00
|
|
|
$self->respond(250,
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
$self->config("me") . " Hi " . $conn->remote_info . " [" . $conn->remote_ip ."]",
|
|
|
|
"PIPELINING",
|
|
|
|
"8BITMIME",
|
|
|
|
($self->config('databytes') ? "SIZE ". ($self->config('databytes'))[0] : ()),
|
|
|
|
@capabilities,
|
|
|
|
);
|
2003-03-18 10:43:22 +01:00
|
|
|
}
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub mail {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->respond(501, "syntax error in parameters") if !$_[0] or $_[0] !~ m/^from:/i;
|
|
|
|
|
|
|
|
# -> from RFC2821
|
|
|
|
# The MAIL command (or the obsolete SEND, SOML, or SAML commands)
|
|
|
|
# begins a mail transaction. Once started, a mail transaction
|
|
|
|
# consists of a transaction beginning command, one or more RCPT
|
|
|
|
# commands, and a DATA command, in that order. A mail transaction
|
|
|
|
# may be aborted by the RSET (or a new EHLO) command. There may be
|
|
|
|
# zero or more transactions in a session. MAIL (or SEND, SOML, or
|
|
|
|
# SAML) MUST NOT be sent if a mail transaction is already open,
|
|
|
|
# i.e., it should be sent only if no mail transaction had been
|
|
|
|
# started in the session, or it the previous one successfully
|
|
|
|
# concluded with a successful DATA command, or if the previous one
|
|
|
|
# was aborted with a RSET.
|
|
|
|
|
|
|
|
# sendmail (8.11) rejects a second MAIL command.
|
|
|
|
|
|
|
|
# qmail-smtpd (1.03) accepts it and just starts a new transaction.
|
|
|
|
# Since we are a qmail-smtpd thing we will do the same.
|
|
|
|
|
|
|
|
$self->reset_transaction;
|
|
|
|
|
|
|
|
unless ($self->connection->hello) {
|
|
|
|
return $self->respond(503, "please say hello first ...");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my $from_parameter = join " ", @_;
|
2004-03-05 13:46:24 +01:00
|
|
|
$self->log(LOGINFO, "full from_parameter: $from_parameter");
|
2004-07-16 04:22:11 +02:00
|
|
|
|
2004-07-20 14:46:20 +02:00
|
|
|
my ($from) = ($from_parameter =~ m/^from:\s*(<[^>]*>)/i)[0];
|
2004-07-16 04:22:11 +02:00
|
|
|
|
|
|
|
# support addresses without <> ... maybe we shouldn't?
|
|
|
|
($from) = "<" . ($from_parameter =~ m/^from:\s*(\S+)/i)[0] . ">"
|
|
|
|
unless $from;
|
|
|
|
|
2004-11-27 07:38:32 +01:00
|
|
|
$self->log(LOGWARN, "from email address : [$from]");
|
2004-11-22 21:50:57 +01:00
|
|
|
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
if ($from eq "<>" or $from =~ m/\[undefined\]/ or $from eq "<#@[]>") {
|
2004-07-15 01:58:47 +02:00
|
|
|
$from = Qpsmtpd::Address->new("<>");
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
else {
|
2004-07-15 01:58:47 +02:00
|
|
|
$from = (Qpsmtpd::Address->parse($from))[0];
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
return $self->respond(501, "could not parse your mail from command") unless $from;
|
|
|
|
|
|
|
|
my ($rc, $msg) = $self->run_hooks("mail", $from);
|
|
|
|
if ($rc == DONE) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
elsif ($rc == DENY) {
|
|
|
|
$msg ||= $from->format . ', denied';
|
2004-03-05 13:46:24 +01:00
|
|
|
$self->log(LOGINFO, "deny mail from " . $from->format . " ($msg)");
|
2002-09-24 12:56:35 +02:00
|
|
|
$self->respond(550, $msg);
|
|
|
|
}
|
|
|
|
elsif ($rc == DENYSOFT) {
|
|
|
|
$msg ||= $from->format . ', temporarily denied';
|
2004-03-05 13:46:24 +01:00
|
|
|
$self->log(LOGINFO, "denysoft mail from " . $from->format . " ($msg)");
|
2002-09-24 12:56:35 +02:00
|
|
|
$self->respond(450, $msg);
|
|
|
|
}
|
2004-06-15 00:25:52 +02:00
|
|
|
elsif ($rc == DENY_DISCONNECT) {
|
2003-12-03 09:07:36 +01:00
|
|
|
$msg ||= $from->format . ', denied';
|
2004-03-05 13:46:24 +01:00
|
|
|
$self->log(LOGINFO, "deny mail from " . $from->format . " ($msg)");
|
2003-12-03 09:07:36 +01:00
|
|
|
$self->respond(550, $msg);
|
|
|
|
$self->disconnect;
|
|
|
|
}
|
2004-06-15 00:25:52 +02:00
|
|
|
elsif ($rc == DENYSOFT_DISCONNECT) {
|
2004-06-11 08:06:30 +02:00
|
|
|
$msg ||= $from->format . ', temporarily denied';
|
|
|
|
$self->log(LOGINFO, "denysoft mail from " . $from->format . " ($msg)");
|
|
|
|
$self->respond(450, $msg);
|
|
|
|
$self->disconnect;
|
|
|
|
}
|
2002-09-24 12:56:35 +02:00
|
|
|
else { # includes OK
|
2004-03-05 13:46:24 +01:00
|
|
|
$self->log(LOGINFO, "getting mail from ".$from->format);
|
2002-09-24 12:56:35 +02:00
|
|
|
$self->respond(250, $from->format . ", sender OK - how exciting to get mail from you!");
|
|
|
|
$self->transaction->sender($from);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub rcpt {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->respond(501, "syntax error in parameters") unless $_[0] and $_[0] =~ m/^to:/i;
|
|
|
|
return $self->respond(503, "Use MAIL before RCPT") unless $self->transaction->sender;
|
|
|
|
|
|
|
|
my ($rcpt) = ($_[0] =~ m/to:(.*)/i)[0];
|
|
|
|
$rcpt = $_[1] unless $rcpt;
|
2004-11-27 07:38:32 +01:00
|
|
|
$self->log(LOGWARN, "to email address : [$rcpt]");
|
2004-07-15 01:58:47 +02:00
|
|
|
$rcpt = (Qpsmtpd::Address->parse($rcpt))[0];
|
2002-09-24 12:56:35 +02:00
|
|
|
|
|
|
|
return $self->respond(501, "could not parse recipient") unless $rcpt;
|
|
|
|
|
|
|
|
my ($rc, $msg) = $self->run_hooks("rcpt", $rcpt);
|
|
|
|
if ($rc == DONE) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
elsif ($rc == DENY) {
|
|
|
|
$msg ||= 'relaying denied';
|
|
|
|
$self->respond(550, $msg);
|
|
|
|
}
|
|
|
|
elsif ($rc == DENYSOFT) {
|
|
|
|
$msg ||= 'relaying denied';
|
2002-10-25 02:24:54 +02:00
|
|
|
return $self->respond(450, $msg);
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
2004-06-15 00:25:52 +02:00
|
|
|
elsif ($rc == DENY_DISCONNECT) {
|
2003-12-03 21:58:30 +01:00
|
|
|
$msg ||= 'delivery denied';
|
2004-03-05 13:46:24 +01:00
|
|
|
$self->log(LOGINFO, "delivery denied ($msg)");
|
2003-12-03 21:58:30 +01:00
|
|
|
$self->respond(550, $msg);
|
|
|
|
$self->disconnect;
|
|
|
|
}
|
2004-06-15 00:25:52 +02:00
|
|
|
elsif ($rc == DENYSOFT_DISCONNECT) {
|
2004-06-11 08:11:27 +02:00
|
|
|
$msg ||= 'relaying denied';
|
|
|
|
$self->log(LOGINFO, "delivery denied ($msg)");
|
|
|
|
$self->respond(450, $msg);
|
|
|
|
$self->disconnect;
|
|
|
|
}
|
2002-09-24 12:56:35 +02:00
|
|
|
elsif ($rc == OK) {
|
|
|
|
$self->respond(250, $rcpt->format . ", recipient ok");
|
|
|
|
return $self->transaction->add_recipient($rcpt);
|
|
|
|
}
|
|
|
|
else {
|
2002-10-14 03:59:04 +02:00
|
|
|
return $self->respond(450, "No plugin decided if relaying is allowed");
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub help {
|
|
|
|
my $self = shift;
|
|
|
|
$self->respond(214,
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
"This is qpsmtpd " . $self->version,
|
|
|
|
"See http://smtpd.develooper.com/",
|
|
|
|
'To report bugs or send comments, mail to <ask@develooper.com>.');
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub noop {
|
|
|
|
my $self = shift;
|
|
|
|
$self->respond(250, "OK");
|
|
|
|
}
|
|
|
|
|
|
|
|
sub vrfy {
|
2004-09-05 06:30:21 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Note, this doesn't support the multiple ambiguous results
|
|
|
|
# documented in RFC2821#3.5.1
|
|
|
|
# I also don't think it provides all the proper result codes.
|
|
|
|
|
|
|
|
my ($rc, $msg) = $self->run_hooks("vrfy");
|
|
|
|
if ($rc == DONE) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
elsif ($rc == DENY) {
|
|
|
|
$self->respond(554, $msg || "Access Denied");
|
|
|
|
$self->reset_transaction();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
elsif ($rc == OK) {
|
|
|
|
$self->respond(250, $msg || "User OK");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else { # $rc == DECLINED or anything else
|
|
|
|
$self->respond(252, "Just try sending a mail and we'll see how it turns out ...");
|
|
|
|
return 1;
|
|
|
|
}
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub rset {
|
|
|
|
my $self = shift;
|
|
|
|
$self->reset_transaction;
|
|
|
|
$self->respond(250, "OK");
|
|
|
|
}
|
|
|
|
|
|
|
|
sub quit {
|
|
|
|
my $self = shift;
|
|
|
|
my ($rc, $msg) = $self->run_hooks("quit");
|
|
|
|
if ($rc != DONE) {
|
|
|
|
$self->respond(221, $self->config('me') . " closing connection. Have a wonderful day.");
|
|
|
|
}
|
|
|
|
$self->disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
sub disconnect {
|
|
|
|
my $self = shift;
|
|
|
|
$self->run_hooks("disconnect");
|
2004-02-24 11:31:12 +01:00
|
|
|
$self->reset_transaction;
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub data {
|
|
|
|
my $self = shift;
|
2004-07-16 09:27:26 +02:00
|
|
|
my ($rc, $msg) = $self->run_hooks("data");
|
|
|
|
if ($rc == DONE) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
elsif ($rc == DENY) {
|
|
|
|
$self->respond(554, $msg || "Message denied");
|
|
|
|
$self->reset_transaction();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
elsif ($rc == DENYSOFT) {
|
|
|
|
$self->respond(451, $msg || "Message denied temporarily");
|
|
|
|
$self->reset_transaction();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
elsif ($rc == DENY_DISCONNECT) {
|
|
|
|
$self->respond(554, $msg || "Message denied");
|
|
|
|
$self->disconnect;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
elsif ($rc == DENYSOFT_DISCONNECT) {
|
|
|
|
$self->respond(451, $msg || "Message denied temporarily");
|
|
|
|
$self->disconnect;
|
|
|
|
return 1;
|
|
|
|
}
|
2005-01-30 18:40:11 +01:00
|
|
|
$self->respond(503, "MAIL first"), return 1 unless $self->transaction->sender;
|
|
|
|
$self->respond(503, "RCPT first"), return 1 unless $self->transaction->recipients;
|
|
|
|
$self->respond(354, "go ahead");
|
2004-07-16 09:27:26 +02:00
|
|
|
|
2002-09-24 12:56:35 +02:00
|
|
|
my $buffer = '';
|
|
|
|
my $size = 0;
|
|
|
|
my $i = 0;
|
|
|
|
my $max_size = ($self->config('databytes'))[0] || 0; # this should work in scalar context
|
|
|
|
my $blocked = "";
|
|
|
|
my %matches;
|
|
|
|
my $in_header = 1;
|
|
|
|
my $complete = 0;
|
|
|
|
|
2004-03-05 13:46:24 +01:00
|
|
|
$self->log(LOGDEBUG, "max_size: $max_size / size: $size");
|
2002-09-24 12:56:35 +02:00
|
|
|
|
|
|
|
my $header = Mail::Header->new(Modify => 0, MailFrom => "COERCE");
|
|
|
|
|
2004-11-19 09:44:24 +01:00
|
|
|
my $timeout = $self->config('timeout');
|
|
|
|
while (defined($_ = $self->getline($timeout))) {
|
2002-09-24 12:56:35 +02:00
|
|
|
$complete++, last if $_ eq ".\r\n";
|
|
|
|
$i++;
|
2004-03-04 05:30:02 +01:00
|
|
|
|
|
|
|
# should probably use \012 and \015 in these checks instead of \r and \n ...
|
|
|
|
|
|
|
|
# Reject messages that have either bare LF or CR. rjkaes noticed a
|
|
|
|
# lot of spam that is malformed in the header.
|
|
|
|
|
|
|
|
($_ eq ".\n" or $_ eq ".\r")
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
and $self->respond(421, "See http://smtpd.develooper.com/barelf.html")
|
|
|
|
and return $self->disconnect;
|
2004-03-04 05:30:02 +01:00
|
|
|
|
2002-09-24 12:56:35 +02:00
|
|
|
# add a transaction->blocked check back here when we have line by line plugin access...
|
|
|
|
unless (($max_size and $size > $max_size)) {
|
|
|
|
s/\r\n$/\n/;
|
2002-12-09 10:08:09 +01:00
|
|
|
s/^\.\./\./;
|
2002-09-24 12:56:35 +02:00
|
|
|
if ($in_header and m/^\s*$/) {
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
$in_header = 0;
|
|
|
|
my @headers = split /^/m, $buffer;
|
2002-09-24 12:56:35 +02:00
|
|
|
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
# ... need to check that we don't reformat any of the received lines.
|
|
|
|
#
|
|
|
|
# 3.8.2 Received Lines in Gatewaying
|
|
|
|
# When forwarding a message into or out of the Internet environment, a
|
|
|
|
# gateway MUST prepend a Received: line, but it MUST NOT alter in any
|
|
|
|
# way a Received: line that is already in the header.
|
2002-09-24 12:56:35 +02:00
|
|
|
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
$header->extract(\@headers);
|
|
|
|
#$header->add("X-SMTPD", "qpsmtpd/".$self->version.", http://smtpd.develooper.com/");
|
2002-10-10 03:49:34 +02:00
|
|
|
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
$buffer = "";
|
2002-09-24 12:56:35 +02:00
|
|
|
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
# FIXME - call plugins to work on just the header here; can
|
|
|
|
# save us buffering the mail content.
|
2002-09-24 12:56:35 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($in_header) {
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
$buffer .= $_;
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
else {
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
$self->transaction->body_write($_);
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$size += length $_;
|
|
|
|
}
|
2004-03-05 13:46:24 +01:00
|
|
|
#$self->log(LOGDEBUG, "size is at $size\n") unless ($i % 300);
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
|
2004-03-05 13:46:24 +01:00
|
|
|
$self->log(LOGDEBUG, "max_size: $max_size / size: $size");
|
2002-09-24 12:56:35 +02:00
|
|
|
|
|
|
|
$self->transaction->header($header);
|
|
|
|
|
2003-09-05 07:10:40 +02:00
|
|
|
my $smtp = $self->connection->hello eq "ehlo" ? "ESMTP" : "SMTP";
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
my $authheader = (defined $self->{_auth} and $self->{_auth} == OK) ?
|
|
|
|
"(smtp-auth username $self->{_auth_user}, mechanism $self->{_auth_mechanism})\n" : "";
|
2003-11-04 23:52:49 +01:00
|
|
|
|
|
|
|
$header->add("Received", "from ".$self->connection->remote_info
|
|
|
|
." (HELO ".$self->connection->hello_host . ") (".$self->connection->remote_ip
|
Changes by jpeacock@cpan.org (John Peacock)
o plugins/check_badmailfromto
- New plugin in the style of check_badmailfrom, which matches a pair
of FROM/TO and makes it seem like the recipient's address no longer
exists (but only from the matching sender's point of view). Useful
for stalkers and other harassment cases.
o plugins/dns_whitelist_soft
- New plugin to provide a DNS-based whitelist (good for distributed
sites).
o various files
- Replaced tab character with 8 spaces and adjusted line breaks for
better readability.
Changes by mct@toren.net (Michael C. Toren)
o lib/Qpsmtpd/SMTP.pm
- Assumes a MAIL FROM value of "<#@[]>" (utilized by qmail to
indicate a null sender when generating a doublebounce message)
is equivalent to "<>". Previously qpsmtpd complained that the
value could not be parsed.
- Adds LOGIN to the default list of supported auth mechanisms.
The documentation in Auth.pm indicated that auth-login was not
currently supported due to lack of functionality, however I can
confirm that LOGIN appears to work fine as tested by using msmtp
(http://msmtp.sourceforge.net/). Are there any indications that
LOGIN support is actually broken in the current implementation?
- Removes the "X-Qpsmtpd-Auth: True" header appended when a message
has been sent by an authenticated user. One problem with such a
header is that it's impossible to say which SMTP hop added it,
and it provides no information which could be used to backtrack
the transaction. I grepped through my mail archives a bit
looking for how other MTAs handled the problem, and decided it
would be best to place this information in the Received: header:
Received: from remotehost (HELO remotehost) (192.168.42.42)
(smtp-auth username foo, mechanism cram-md5)
by mail.netisland.net (qpsmtpd/0.28) with ESMTP; <date>
o lib/Qpsmtpd/Auth.pm:
- Documentation update for the arguments passed to an auth
handler; previously the $mechanism argument was not mentioned,
which threw off the argument offsets.
- Documentation update for auth-login removing the warning
that auth-login is not currently supported due to lack of
functionality.
- Fix to execute a generic auth hook when a more specific
auth-$mechanism hook does not exist. (Previously posted
to the list last week.)
- Upon authentication, sets $session->{_auth_user} and
$session->{_auth_mechanism} so that SMTP.pm can include them
in the Received: header.
o plugins/queue/qmail-queue
- Added a timestamp and the qmail-queue qp identifier to the
"Queued!" 250 message, for compatibility with qmail-smtpd, which
can be very useful for tracking message delivery from machine to
machine. For example, the new 250 message might be:
250 Queued! 1105927468 qp 3210 <1105927457@netisland.net>
qmail-smtpd returns:
250 ok 1106546213 qp 7129
Additionally, for consistency angle brackets are placed around
the Message-ID displayed in the 250 if they were missing in the
message header.
o plugins/check_badmailfrom:
- Changed the error message from "Mail from $bad not accepted
here" to "sorry, your envelope sender is in my badmailfrom
list", for compatibility with qmail-smtpd. I didn't see any
reason to share with the sender the value of $bad, especially
for situations where the sender was rejected resulting from a
wildcard.
o plugins/check_earlytalker:
o plugins/require_resolvable_fromhost:
- No longer checks for earlytalkers or resolvable senders if the
connection note "whitelistclient" is set, which is nice for
helping backup MX hosts empty their queue faster.
o plugins/count_unrecognized_commands:
- Return code changed from DENY_DISCONNECT, which isn't valid in
an unrecognized_command hook, to DENY, which in this context
drops the connection anyway. (Previously posted to the list
last week.)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@356 958fd67b-6ff1-0310-b445-bb7760255be9
2005-01-28 04:30:50 +01:00
|
|
|
. ")\n $authheader by ".$self->config('me')." (qpsmtpd/".$self->version
|
2003-11-04 23:52:49 +01:00
|
|
|
.") with $smtp; ". (strftime('%a, %d %b %Y %H:%M:%S %z', localtime)),
|
|
|
|
0);
|
2002-09-24 12:56:35 +02:00
|
|
|
|
|
|
|
# if we get here without seeing a terminator, the connection is
|
|
|
|
# probably dead.
|
|
|
|
$self->respond(451, "Incomplete DATA"), return 1 unless $complete;
|
|
|
|
|
|
|
|
#$self->respond(550, $self->transaction->blocked),return 1 if ($self->transaction->blocked);
|
|
|
|
$self->respond(552, "Message too big!"),return 1 if $max_size and $size > $max_size;
|
|
|
|
|
2004-07-16 11:44:39 +02:00
|
|
|
($rc, $msg) = $self->run_hooks("data_post");
|
2002-09-24 12:56:35 +02:00
|
|
|
if ($rc == DONE) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
elsif ($rc == DENY) {
|
|
|
|
$self->respond(552, $msg || "Message denied");
|
|
|
|
}
|
|
|
|
elsif ($rc == DENYSOFT) {
|
|
|
|
$self->respond(452, $msg || "Message denied temporarily");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->queue($self->transaction);
|
|
|
|
}
|
|
|
|
|
|
|
|
# DATA is always the end of a "transaction"
|
|
|
|
return $self->reset_transaction;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-09-14 07:48:39 +02:00
|
|
|
sub getline {
|
2004-11-19 09:44:24 +01:00
|
|
|
my ($self, $timeout) = @_;
|
2004-09-14 07:48:39 +02:00
|
|
|
|
|
|
|
alarm $timeout;
|
|
|
|
my $line = <STDIN>; # default implementation
|
|
|
|
alarm 0;
|
|
|
|
return $line;
|
|
|
|
}
|
|
|
|
|
2002-09-24 12:56:35 +02:00
|
|
|
sub queue {
|
|
|
|
my ($self, $transaction) = @_;
|
|
|
|
|
2002-10-10 03:49:34 +02:00
|
|
|
my ($rc, $msg) = $self->run_hooks("queue");
|
|
|
|
if ($rc == DONE) {
|
|
|
|
return 1;
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
2002-10-10 03:49:34 +02:00
|
|
|
elsif ($rc == OK) {
|
|
|
|
$self->respond(250, ($msg || 'Queued'));
|
|
|
|
}
|
|
|
|
elsif ($rc == DENY) {
|
|
|
|
$self->respond(552, $msg || "Message denied");
|
|
|
|
}
|
|
|
|
elsif ($rc == DENYSOFT) {
|
|
|
|
$self->respond(452, $msg || "Message denied temporarily");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->respond(451, $msg || "Queuing declined or disabled; try again later" );
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
|
2002-10-10 03:49:34 +02:00
|
|
|
|
2002-09-24 12:56:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
1;
|