[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#465342: libmime-lite-perl: Unusable without mail-transport-agent



On Tue, Feb 12, 2008 at 09:23:34PM +0100, gregor herrmann wrote:
> On Tue, 12 Feb 2008 17:40:18 +0000, Dominic Hargreaves wrote:

> > I don't really think that's appropriate either. I haven't checked the
> > behaviour of MIME::Lite with this conditional section removed (ie as per
> > the patch on rt.cpan.org) but really it should behave gracefully itself.
> 
> Agreed.
> 
> > carp()ing isn't really appropriate here either. The error only needs to
> > appear if send_by_sendmail is used, and send should select sendmail if
> > available, and not otherwise.
> 
> Right, that would involve moving the test into to send_by_sendmail()
> method.

Here are the possibilities:

dom@callisto:~$ cat mime-lite-test 
#!/usr/bin/perl

use MIME::Lite;

my $msg = MIME::Lite->new(
    From => 'dom@earth.li',
    To   => 'dom@earth.li',
    Subject => 'test',
    Data => 'foo' );

$msg->send;
<end>

1) sendmail preparation step looks for a sendmail, and sets the default
   send method to 'smtp', like on win32, if no sendmail found:

Failure mode:

dom@callisto:~$ ./mime-lite-test 
SMTP Failed to connect to mail server: Bad file descriptor
 at ./mime-lite-test line 11

(if no SMTP server configured in /etc/perl/Net/libnet.cfg).

At first glance, this seemed to be the most correct solution,
but the error message ends up being less than helpful (since Net::SMTP
doesn't do anything better).

2) as you suggested, replace croak with carp:

dom@callisto:~$ ./mime-lite-test
can't find an executable sendmail at ./mime-lite-test line 3
open |sendmail -t -oi -oem: No such file or directory
 at /home/dom/mime-lite-test line 11

This, as it stands, is probably worse - no point in two separate errors

3) Check in send_by_sendmail (and no check in the place where croak used
to be)

dom@callisto:~$ ./mime-lite-test
no sendmail command defined at /home/dom/mime-lite-test line 11

There seems to be no really sensible solution to this, since sendmail
will be assumed to be present on Unix systems where code using this
module is deployed. I'm half-inclined just to suggest putting in back in
Depends. But I assume the original requestor had a good reason for not
wanting to have mail-transport-agent installed, and it does make sense
in small system/embedded environments.

None of those options are more than a few lines of patch (so much so
that I haven't bothered to preserve the code used to test them) but I
think on reflection I prefer option three, since option one is probably
going to arise for nearly everyone anyway, since I suspect the Net::SMTP
config doesn't have an SMTP server in the vast majority of most running
Debian boxes (and it's quite a jump to start sending things via SMTP
when the person writing the code knowing it was going to run on a unix
system expected it to be sent via sendmail if at all).

Any other comments? If we can agree on the third, I'll update the
upstream bug with a patch, and get our package in shape and uploaded to
fix this rather annoying bug :)

Dominic.

-- 
Dominic Hargreaves | http://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)


Reply to: