summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2006-03-21 07:04:07 +0000
committerfukachan <fukachan>2006-03-21 07:04:07 +0000
commit2c7ca6930a8fba9d9278bf3e4c5a48bff6c6fa40 (patch)
tree6cf7e34b01ee32372a127a492743f84f91db73d7
parentee06332ac474ce11f83d0b20f8fba7bd923f74f2 (diff)
downloadfml8-2c7ca6930a8fba9d9278bf3e4c5a48bff6c6fa40.tar.gz
fml8-2c7ca6930a8fba9d9278bf3e4c5a48bff6c6fa40.tar.bz2
fml8-2c7ca6930a8fba9d9278bf3e4c5a48bff6c6fa40.zip
validate format of recipient within smtp transaction.
-rw-r--r--fml/lib/FML/Mailer.pm10
-rw-r--r--fml/lib/FML/Process/Distribute.pm14
-rw-r--r--fml/lib/Mail/Delivery/SMTP.pm22
3 files changed, 42 insertions, 4 deletions
diff --git a/fml/lib/FML/Mailer.pm b/fml/lib/FML/Mailer.pm
index 77531481..60d1a115 100644
--- a/fml/lib/FML/Mailer.pm
+++ b/fml/lib/FML/Mailer.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Mailer.pm,v 1.31 2005/06/04 08:49:05 fukachan Exp $
+# $FML: Mailer.pm,v 1.32 2005/06/04 08:51:30 fukachan Exp $
#
package FML::Mailer;
@@ -193,6 +193,13 @@ sub send
return 0;
}
+ # address validater
+ my $validater = sub {
+ my ($address) = @_;
+ use FML::Restriction::Base;
+ my $restriction = new FML::Restriction::Base;
+ return $restriction->regexp_match( 'address', $address );
+ };
#
# main
@@ -203,6 +210,7 @@ sub send
log_function => $fp,
smtp_log_function => $sfp,
smtp_log_handle => $handle,
+ address_validate_function => $validater,
};
if ($service->error) { $curproc->logerror($service->error); return 0;}
diff --git a/fml/lib/FML/Process/Distribute.pm b/fml/lib/FML/Process/Distribute.pm
index f38851e9..082748da 100644
--- a/fml/lib/FML/Process/Distribute.pm
+++ b/fml/lib/FML/Process/Distribute.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2000,2001,2002,2003,2004,2005,2006 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: Distribute.pm,v 1.169 2006/02/04 07:42:24 fukachan Exp $
+# $FML: Distribute.pm,v 1.170 2006/03/19 08:06:05 fukachan Exp $
#
package FML::Process::Distribute;
@@ -609,11 +609,22 @@ sub _deliver_article
$sfp = sub { print $wh @_;};
$handle = undef; # $wh;
}
+ else {
+ $curproc->logerror("cannot open outgoing_message_cache");
+ }
}
else {
$sfp = sub {};
}
+ # address validater
+ my $validater = sub {
+ my ($address) = @_;
+ use FML::Restriction::Base;
+ my $restriction = new FML::Restriction::Base;
+ return $restriction->regexp_match( 'address', $address );
+ };
+
# delay loading of module
my $service = {};
eval q{
@@ -622,6 +633,7 @@ sub _deliver_article
log_function => $fp,
smtp_log_function => $sfp,
smtp_log_handle => $handle,
+ address_validate_function => $validater,
};
};
croak($@) if $@;
diff --git a/fml/lib/Mail/Delivery/SMTP.pm b/fml/lib/Mail/Delivery/SMTP.pm
index 688f1820..840f230a 100644
--- a/fml/lib/Mail/Delivery/SMTP.pm
+++ b/fml/lib/Mail/Delivery/SMTP.pm
@@ -4,13 +4,13 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: SMTP.pm,v 1.33 2004/08/14 08:35:52 fukachan Exp $
+# $FML: SMTP.pm,v 1.34 2004/08/15 11:59:05 fukachan Exp $
#
package Mail::Delivery::SMTP;
use strict;
-use vars qw(@ISA @EXPORT @EXPORT_OK);
+use vars qw(@ISA @EXPORT @EXPORT_OK $fp_address_validate);
use Carp;
use IO::Socket;
use Mail::Delivery::Utils;
@@ -147,6 +147,7 @@ sub new
# define package global pointer to the log() function
$LogFunctionPointer = $args->{log_function} || undef;
$SmtpLogFunctionPointer = $args->{smtp_log_function} || undef;
+ $fp_address_validate = $args->{address_validate_function} || undef;
bless $me, $type;
@@ -873,7 +874,24 @@ sub _send_recipient_list_by_recipient_map
# XXX $obj->get_recipient returns a mail address.
RCPT_INPUT:
while (defined ($rcpt = $obj->get_next_key)) {
+ # firstly, validate the format of the specified address $rcpt.
+ if (defined $fp_address_validate) {
+ my $r = 0;
+ eval q{ $r = &$fp_address_validate($rcpt);};
+ unless ($@) {
+ unless ($r) {
+ $self->smtplog("===> ignore <$rcpt>");
+ Log("ignore <$rcpt>");
+ next RCPT_INPUT;
+ }
+ }
+ else {
+ Log("\$fp_address_validate failes");
+ }
+ }
+
$num_recipients++;
+
$self->_send_command("RCPT TO:<$rcpt>");
$self->_read_reply;