Subject: Developers of Sympa
List archive
- From: Fil <address@concealed>
- To: Sympa-Dev <address@concealed>
- Subject: smtp direct sending
- Date: Mon, 3 Sep 2001 12:37:34 +0200
Dear all,
to make sympa work better with postfix, several postfix specialists say that
we should send the mail via a direct smtp connection, and not via the
sendmail programme. How to do it efficiently ? I have toyed with the idea
of using a small external programm that would be invoked like sendmail, but
this is not the best idea : it looks easy to code a SMTP client inside
sympa, using the NET::SMTP module. I've played a bit with it and the
following code seems OK. It gets errors if and only if there is an error
- connecting to smtp OR
- sending the data
ie it does not fail when an address is refused by the smtp server (a badly
formed address for example), so we don't have to deal with knowing what
addresses went through and which did not.
My problem is to integrate it within sympa :
I suppose we must play inside bin/joe smtp.pm around these lines
if (ref($rcpt) eq 'SCALAR') {
exec $Conf{'sendmail'}, '-oi', '-odi', '-oem', '-f', $from,
$$rcpt;
}else{
exec $Conf{'sendmail'}, '-oi', '-odi', '-oem', '-f', $from,
@$rcpt;
}
and add a Conf{'smtpdirect'} option that gives, in the right order, the
names of the smtp servers to try (for ex. 'localhost', 'stmp.provider.net',
'sendmail'... where 'sendmail' means : fall back to the classic sendmail
sending.
But I am troubled by the complexity of the sympa code :
- checking for the number of active sendmail processes
- exec
I would need explanations about this to implement the smtp client, perhaps
in a seperate file named smtp_direct.pm -- that would be either included by
smtp.pm or would replace it ?
So this is open for comments....
%%%%%%%%%%%% smtp_test.pl
use strict;
use Net::SMTP;
my $errs;
my @result = ();
my $to = join(' ',
('address@concealed', 'address@concealed',
'address@concealed', 'address@concealed'));
if (@result =
smtp_send(
'address@concealed',
'address@concealed',
$to,
'localhost',
'Perl mailer',
'Hello Fil'
)) { # ici traiter l'erreur : envoi via sendmail + log
# ou essai d'envoi via un autre smtp (de secours ou hébergeur)
## appel sendmail
#XXXXXXXXXXXXXXXXXX à compléter
}
sub smtp_send {
my ($from, $reply, $to, $host, $subject, $message) = @_;
my $smtp;
my @errs = ();
$smtp = Net::SMTP->new($host) || return $@;
$smtp->mail($from)
|| push @errs, "mailer: error in sender address \"$from\"";
$to =~ s/,\s*|\s+/, /g;
foreach (split(/, /, $to)) {
$smtp->to($_);
# || push @errs, "mailer: error adding recipient
\"$_\"";
}
$smtp->data()
|| push @errs, "mailer: error initiating the sending of data";
$smtp->datasend("To: \n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Reply-to: $from\n");
$smtp->datasend("X-Mailer: Perl mailer\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend("$message\n");
$smtp->dataend() || push @errs, "mailer: error sending data";
$smtp->quit || push @errs, $@;
return @errs;
}
%%%%%%%%%%%%%%%%%%%%%%%
-- Fil
- smtp direct sending, Fil, 09/03/2001
Archive powered by MHonArc 2.6.19+.