Skip Menu |

This queue is for tickets about the Mail-Box CPAN distribution.

Report information
The Basics
Id: 64266
Status: resolved
Priority: 0/
Queue: Mail-Box

People
Owner: Nobody in particular
Requestors: andy [...] andybev.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.096
Fixed in: (no value)



Subject: Problems with overruling addresses using destinations()
Mail-box-2.096 Perl 5.10.0 Linux 2.6.30.1-m64-mb1 #2 SMP x86_64 GNU/Linux I am having trouble with Mail::Transport::Send->destinations() which I believe to be a bug. The following code sends an email to "andy@andybev.com", whereas I would expect it to send to "mail@andybev.com" use Mail::Message; use Mail::Transport::SMTP; $msg = Mail::Message->build ( From => 'andy@andybev.com' , To => 'andy@andybev.com' , Subject => "Test message" , data => "Test body" ); my $sender = Mail::Transport::SMTP->new(); $sender->destinations($msg, 'mail@andybev.com'); $sender->send($msg); I have looked at the code to try and rectify the problem, but my perl knowledge is not good enough. However, as an additional point, I did notice that in Sendmail.pm the code is not suitable for destinations() anyway - the sendmail binary is called with '-t'. I believe that Sendmail should only be called with '-t' if the recipient addresses have not been overruled. So, there appears to be 2 related bugs: the destinations() parameter does not function as expected for *all* mailer transports, and Sendmail should not always be called with '-t'. Thanks, Andy
Subject: Re: [rt.cpan.org #64266] Problems with overruling addresses using destinations()
Date: Tue, 28 Dec 2010 00:49:57 +0100
To: Andrew Beverley via RT <bug-Mail-Box [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* Andrew Beverley via RT (bug-Mail-Box@rt.cpan.org) [101227 19:01]: Show quoted text
> Mon Dec 27 14:01:05 2010: Request 64266 was acted upon. > my $sender = Mail::Transport::SMTP->new(); > $sender->destinations($msg, 'mail@andybev.com'); > $sender->send($msg); >
"destinations()" is not a setter, but a method which computes the destination. It is called by send(). So, what should work is my $sender = Mail::Transport::SMTP->new(); $sender->send($msg, To => 'mail@andybev.com'); Show quoted text
> I have looked at the code to try and rectify the problem, but my perl > knowledge is not good enough. However, as an additional point, I did > notice that in Sendmail.pm the code is not suitable for destinations() > anyway - the sendmail binary is called with '-t'. I believe that > Sendmail should only be called with '-t' if the recipient addresses have > not been overruled.
This depends on the "sendmail" you have. Most people have postfixes version, nowadays. Its documentation says: -t Extract recipients from message headers. These are added to any recipients specified on the command line. With Postfix versions prior to 2.1, this option requires that no recipient addresses are specified on the command line. I remember to have added the '-t' later, but am not sure it is correct (in general or for your version). Probably you are right: when overruled then the -t should disappear... Try it! -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
From: andy [...] andybev.com
On Mon Dec 27 18:50:15 2010, solutions@overmeer.net wrote: Show quoted text
> * Andrew Beverley via RT (bug-Mail-Box@rt.cpan.org) [101227 19:01]:
> > Mon Dec 27 14:01:05 2010: Request 64266 was acted upon. > > my $sender = Mail::Transport::SMTP->new(); > > $sender->destinations($msg, 'mail@andybev.com'); > > $sender->send($msg); > >
> > "destinations()" is not a setter, but a method which computes the > destination. It is called by send(). So, what should work is > > my $sender = Mail::Transport::SMTP->new(); > $sender->send($msg, To => 'mail@andybev.com'); >
Thanks for your prompt response. Yes, that works for SMTP (although using 'to' not 'To'). Sorry for wasting your time on that one :) Show quoted text
> > This depends on the "sendmail" you have. Most people have postfixes > version, nowadays. Its documentation says: >
I am indeed using Postfix - I should have said. Show quoted text
> -t Extract recipients from message headers. These are added to any > recipients specified on the command line. > > With Postfix versions prior to 2.1, this option requires that no > recipient addresses are specified on the command line. > > I remember to have added the '-t' later, but am not sure it is correct > (in general or for your version). Probably you are right: when > overruled then the -t should disappear... Try it!
I just tried it, and the override doesn't work for the Sendmail target. I don't think that there is any need for a '-t' at all. I think Sendmail.pm should be changed to be the same as Exim.pm, so that it calculates the recipient if none have been specified, or overrides if they have. The attached patch Works For Me (TM). Thanks, Andy
Subject: sendmail-override.patch
*** Sendmail.pm 2010-11-09 09:05:35.000000000 +0000 --- /usr/local/share/perl/5.10.0/Mail/Transport/Sendmail.pm 2010-12-28 08:31:27.000000000 +0000 *************** *** 36,47 **** sub trySend($@) { my ($self, $message, %args) = @_; my $program = $self->{MTS_program}; if(open(MAILER, '|-')==0) { my $options = $args{sendmail_options} || []; # {} to avoid warning ! { exec $program, '-ti', @{$self->{MTS_opts}}, @$options; } $self->log(NOTICE => "Errors when opening pipe to $program: $!"); exit 1; --- 36,48 ---- sub trySend($@) { my ($self, $message, %args) = @_; + my @to = map {$_->address} $self->destinations($message, $args{to}); my $program = $self->{MTS_program}; if(open(MAILER, '|-')==0) { my $options = $args{sendmail_options} || []; # {} to avoid warning ! { exec $program, '-i', @{$self->{MTS_opts}}, @$options, @to; } $self->log(NOTICE => "Errors when opening pipe to $program: $!"); exit 1;
Subject: Re: [rt.cpan.org #64266] Problems with overruling addresses using destinations()
Date: Tue, 28 Dec 2010 10:21:30 +0100
To: Andrew Beverley via RT <bug-Mail-Box [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* Andrew Beverley via RT (bug-Mail-Box@rt.cpan.org) [101228 08:50]: Show quoted text
> Queue: Mail-Box > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=64266 > > > The attached patch Works For Me (TM).
Solid fix. Only moved @to= inside the open(). If you are in a hurry, I can release a new distribution. Otherwise, it may take a few weeks. -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
From: andy [...] andybev.com
On Tue Dec 28 04:21:45 2010, solutions@overmeer.net wrote: Show quoted text
> * Andrew Beverley via RT (bug-Mail-Box@rt.cpan.org) [101228 08:50]:
> > Queue: Mail-Box > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=64266 > > > > > The attached patch Works For Me (TM).
> > Solid fix. Only moved @to= inside the open(). > If you are in a hurry, I can release a new distribution. Otherwise, it > may take a few weeks.
That's fantastic. No need for a new release as I can make the changes myself until the new version is released. Thanks for the brilliant support - I really appreciate it. Andy
got fixed in 2.097