Mail::Address does RFC822 addresses, we need SMTP addresses.

Replace Mail::Address with Peter J. Holzer's Qpsmtpd::Address module.


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@261 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Ask Bjørn Hansen 2004-07-14 23:58:47 +00:00
parent d7eb8673d1
commit 87323ed62e
5 changed files with 58 additions and 9 deletions

View File

@ -1,3 +1,11 @@
0.29 -
[ many changes from cvs logs, gah ]
Mail::Address does RFC822 addresses, we need SMTP addresses.
Replace Mail::Address with Peter J. Holzer's Qpsmtpd::Address module.
0.28 - 2004/06/05
Don't keep adding ip addresses to the process status line ($0) when running under PPerl.

5
STATUS
View File

@ -4,7 +4,7 @@ Near term roadmap
0.29:
- Add the first time denysoft plugin
- Support email addresses with spaces in them
- Support email addresses with spaces in them (done)
- Bugfixes
0.40:
@ -29,6 +29,9 @@ Near term roadmap
Issues
======
Understand "extension parameters" to the MAIL FROM and RCPT TO
parameters (and make the plugin hooks able to get at them).
plugins/queue/qmail-queue is still calling exit inappropriately
(should call disconnect or some such)

View File

@ -11,8 +11,8 @@ use Qpsmtpd::Transaction;
use Qpsmtpd::Plugin;
use Qpsmtpd::Constants;
use Qpsmtpd::Auth;
use Qpsmtpd::Address ();
use Mail::Address ();
use Mail::Header ();
#use Data::Dumper;
use POSIX qw(strftime);
@ -229,10 +229,10 @@ sub mail {
my ($from) = ($from_parameter =~ m/^from:\s*(\S+)/i)[0];
warn "$$ from email address : [$from]\n";
if ($from eq "<>" or $from =~ m/\[undefined\]/) {
$from = Mail::Address->new("<>");
$from = Qpsmtpd::Address->new("<>");
}
else {
$from = (Mail::Address->parse($from))[0];
$from = (Qpsmtpd::Address->parse($from))[0];
}
return $self->respond(501, "could not parse your mail from command") unless $from;
@ -277,7 +277,7 @@ sub rcpt {
my ($rcpt) = ($_[0] =~ m/to:(.*)/i)[0];
$rcpt = $_[1] unless $rcpt;
$rcpt = (Mail::Address->parse($rcpt))[0];
$rcpt = (Qpsmtpd::Address->parse($rcpt))[0];
return $self->respond(501, "could not parse recipient") unless $rcpt;

View File

@ -160,14 +160,14 @@ latter is done for you by qpsmtpd.
This adds a new recipient (as in RCPT TO) to the envelope of the mail.
The C<$recipient> is a C<Mail::Address> object. See L<Mail::Address>
The C<$recipient> is a C<Qpsmtpd::Address> object. See L<Qpsmtpd::Address>
for more details.
=head2 recipients( )
This returns a list of the current recipients in the envelope.
Each recipient returned is a C<Mail::Address> object.
Each recipient returned is a C<Qpsmtpd::Address> object.
=head2 relaying( )
@ -178,7 +178,7 @@ by the C<check_relay> plugin.
Get or set the sender (MAIL FROM) address in the envelope.
The sender is a C<Mail::Address> object.
The sender is a C<Qpsmtpd::Address> object.
=head2 header( [ HEADER ] )
@ -225,6 +225,6 @@ Returns a single line of data from the body of the email.
=head1 SEE ALSO
L<Mail::Header>, L<Mail::Address>
L<Mail::Header>, L<Qpsmtpd::Address>, L<Qpsmtpd::Connection>
=cut

38
t/qpsmtpd-address.t Normal file
View File

@ -0,0 +1,38 @@
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 9;
BEGIN {
use_ok('Qpsmtpd::Address');
}
my $as;
my $ao;
$as = '<>';
$ao = Qpsmtpd::Address->parse($as);
ok ($ao, "parse $as");
is ($ao->format, $as, "format $as");
$as = '<foo@example.com>';
$ao = Qpsmtpd::Address->parse($as);
ok ($ao, "parse $as");
is ($ao->format, $as, "format $as");
# the \ before the @ in the local part is not required, but
# allowed. For simplicity we add a backslash before all characters
# which are not allowed in a dot-string.
$as = '<"musa_ibrah@caramail.comandrea.luger"@wifo.ac.at>';
$ao = Qpsmtpd::Address->parse($as);
ok ($ao, "parse $as");
is ($ao->format, '<"musa_ibrah\@caramail.comandrea.luger"@wifo.ac.at>', "format $as");
# email addresses with spaces
$as = '<foo bar@example.com>';
$ao = Qpsmtpd::Address->parse($as);
ok ($ao, "parse $as");
is ($ao->format, '<"foo\ bar"@example.com>', "format $as");