1# Copyrights 2001-2020 by [Mark Overmeer].
2#  For other contributors see ChangeLog.
3# See the manual pages for details on the licensing terms.
4# Pod stripped from pm file by OODoc 2.02.
5# This code is part of distribution Mail-Transport.  Meta-POD processed with
6# OODoc into POD and HTML manual-pages.  See README.md
7# Copyright Mark Overmeer.  Licensed under the same terms as Perl itself.
8
9package Mail::Transport::Qmail;
10use vars '$VERSION';
11$VERSION = '3.005';
12
13use base 'Mail::Transport::Send';
14
15use strict;
16use warnings;
17
18use Carp;
19
20
21sub init($)
22{   my ($self, $args) = @_;
23
24    $args->{via} = 'qmail';
25
26    $self->SUPER::init($args) or return;
27
28    $self->{MTM_program}
29      = $args->{proxy}
30     || $self->findBinary('qmail-inject', '/var/qmail/bin')
31     || return;
32
33    $self;
34}
35
36#------------------------------------------
37
38
39sub trySend($@)
40{   my ($self, $message, %args) = @_;
41
42    my $program = $self->{MTM_program};
43    if(open(MAILER, '|-')==0)
44    {   { exec $program; }
45        $self->log(NOTICE => "Errors when opening pipe to $program: $!");
46        exit 1;
47    }
48
49    $self->putContent($message, \*MAILER, undisclosed => 1);
50
51    unless(close MAILER)
52    {   $self->log(ERROR => "Errors when closing Qmail mailer $program: $!");
53        $? ||= $!;
54        return 0;
55    }
56
57    1;
58}
59
60#------------------------------------------
61
621;
63