70
71
Sending:
72
--envelope-sender <str> * Email envelope sender.
73
+ --sendmail-cmd <str> * Command to run to send email.
74
--smtp-server <str:int> * Outgoing SMTP server to use. The port
75
is optional. Default 'localhost'.
76
--smtp-server-option <str> * Outgoing SMTP server option to use.
244
my (@suppress_cc);
245
my ($auto_8bit_encoding);
246
my ($compose_encoding);
247
+my ($sendmail_cmd);
248
# Variables with corresponding config settings & hardcoded defaults
249
my ($debug_net_smtp) = 0; # Net::SMTP, see send_message()
250
my $thread = 1;
292
"assume8bitencoding" => \$auto_8bit_encoding,
293
"composeencoding" => \$compose_encoding,
294
"transferencoding" => \$target_xfer_encoding,
295
+ "sendmailcmd" => \$sendmail_cmd,
296
);
297
298
my %config_path_settings = (
426
"no-bcc" => \$no_bcc,
427
"chain-reply-to!" => \$chain_reply_to,
428
"no-chain-reply-to" => sub {$chain_reply_to = 0},
429
+ "sendmail-cmd=s" => \$sendmail_cmd,
430
"smtp-server=s" => \$smtp_server,
431
"smtp-server-option=s" => \@smtp_server_options,
432
"smtp-server-port=s" => \$smtp_server_port,
1000
$reply_to = sanitize_address($reply_to);
1001
}
1002
999
-if (!defined $smtp_server) {
1003
+if (!defined $sendmail_cmd && !defined $smtp_server) {
1004
my @sendmail_paths = qw( /usr/sbin/sendmail /usr/lib/sendmail );
1005
push @sendmail_paths, map {"$_/sendmail"} split /:/, $ENV{PATH};
1006
foreach (@sendmail_paths) {
1007
if (-x $_) {
1004
- $smtp_server = $_;
1008
+ $sendmail_cmd = $_;
1009
last;
1010
}
1011
}
1008
- $smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*
1012
+
1013
+ if (!defined $sendmail_cmd) {
1014
+ $smtp_server = 'localhost'; # could be 127.0.0.1, too... *shrug*
1015
+ }
1016
}
1017
1018
if ($compose && $compose > 0) {
1492
1493
if ($dry_run) {
1494
# We don't want to send the email.
1488
- } elsif (file_name_is_absolute($smtp_server)) {
1495
+ } elsif (defined $sendmail_cmd || file_name_is_absolute($smtp_server)) {
1496
my $pid = open my $sm, '|-';
1497
defined $pid or die $!;
1498
if (!$pid) {
1492
- exec($smtp_server, @sendmail_parameters) or die $!;
1499
+ if (defined $sendmail_cmd) {
1500
+ exec ("sh", "-c", "$sendmail_cmd \"\$@\"", "-", @sendmail_parameters)
1501
+ or die $!;
1502
+ } else {
1503
+ exec ($smtp_server, @sendmail_parameters)
1504
+ or die $!;
1505
+ }
1506
}
1507
print $sm "$header\n$message";
1508
close $sm or die $!;
1598
printf($dry_run ? __("Dry-Sent %s\n") : __("Sent %s\n"), $subject);
1599
} else {
1600
print($dry_run ? __("Dry-OK. Log says:\n") : __("OK. Log says:\n"));
1588
- if (!file_name_is_absolute($smtp_server)) {
1601
+ if (!defined $sendmail_cmd && !file_name_is_absolute($smtp_server)) {
1602
print "Server: $smtp_server\n";
1603
print "MAIL FROM:<$raw_from>\n";
1604
foreach my $entry (@recipients) {
1605
print "RCPT TO:<$entry>\n";
1606
}
1607
} else {
1595
- print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
1608
+ my $sm;
1609
+ if (defined $sendmail_cmd) {
1610
+ $sm = $sendmail_cmd;
1611
+ } else {
1612
+ $sm = $smtp_server;
1613
+ }
1614
+
1615
+ print "Sendmail: $sm ".join(' ',@sendmail_parameters)."\n";
1616
}
1617
print $header, "\n";
1618
if ($smtp) {