Email::Send::Qmail - Send Messages using qmail-inject


Email-Send documentation Contained in the Email-Send distribution.

Index


Code Index:

NAME

Top

Email::Send::Qmail - Send Messages using qmail-inject

SYNOPSIS

Top

  use Email::Send;

  Email::Send->new({mailer => 'Qmail'})->send($message);

DESCRIPTION

Top

This mailer for Email::Send uses qmail-inject to put a message in the Qmail spool. It does not try hard to find the executable. It just calls qmail-inject and expects it to be in your path. If that's not the case, or you want to explicitly define the location of your executable, alter the $Email::Send::Qmail::QMAIL package variable.

  $Email::Send::Qmail::QMAIL = '/usr/sbin/qmail-inject';

SEE ALSO

Top

Email::Send, perl.

AUTHOR

Top

Current maintainer: Ricardo SIGNES, <rjbs@cpan.org>.

Original author: Casey West, <casey@geeknest.com>.

COPYRIGHT

Top


Email-Send documentation Contained in the Email-Send distribution.

package Email::Send::Qmail;
use strict;

use File::Spec ();
use Return::Value;
use Symbol qw(gensym);

use vars qw[$QMAIL $VERSION];
$QMAIL   ||= q[qmail-inject];
$VERSION   = '2.198';

sub is_available {
    my $class = shift;


    return failure "No qmail found" unless $class->_find_qmail;
    return success;
}

sub _find_qmail {
    my $class = shift;

    my $sendmail;

    if (-x $QMAIL) {
      return $QMAIL;
    }

    for my $dir (File::Spec->path) {
        if ( -x "$dir/$QMAIL" ) {
            $sendmail = "$dir/$QMAIL";
            last;
        }
    }
    return $sendmail;
}

sub send {
    my ($class, $message, @args) = @_;

    my $pipe = gensym;

    open $pipe, "| $QMAIL @args"
        or return failure "couldn't open pipe to qmail";

    print $pipe $message->as_string
        or return failure "couldn't send message to qmail";

    close $pipe
        or return failure "error when closing pipe to qmail";

    return success;
}

1;

__END__