From: "Robin H\. Johnson" <robbat2@gentoo.org>
To: git@vger.kernel.org
Cc: junkio@cox.net, Robin@orbis-terrarum.net,
H.Johnson@orbis-terrarum.net, <robbat2@gentoo.org>
Subject: [PATCH] Make envelope-sender fully configurable.
Date: Tue, 10 Apr 2007 15:02:14 -0700 [thread overview]
Message-ID: <1176242534838-git-send-email-robbat2@gentoo.org> (raw)
In-Reply-To: <11762425341841-git-send-email-robbat2@gentoo.org>
From: Robin H. Johnson <robbat2@gentoo.org>
This patch makes envelope sender fully configurable, and also allows it to be
use with Net::SMTP instead of just the sendmail binary.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
---
git-send-email.perl | 30 ++++++++++++++++++------------
1 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 2436aec..133a844 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -76,6 +76,8 @@ Options:
--quiet Make git-send-email less verbose. One line per email
should be all that is output.
+ --envelope-sender Specify the sender address used for the email envelope.
+
EOT
exit(1);
}
@@ -130,7 +132,8 @@ my $compose_filename = ".msg.$$";
# Variables we fill in automatically, or via prompting:
my (@to,@cc,@initial_cc,@bcclist,@xh,
- $initial_reply_to,$initial_subject,@files,$from,$compose,$time);
+ $initial_reply_to,$initial_subject,@files,$from,$compose,$time,
+ $envelope_sender);
# Behavior modification variables
my ($chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc,
@@ -169,6 +172,7 @@ my $rc = GetOptions("from=s" => \$from,
"bcc=s" => \@bcclist,
"chain-reply-to!" => \$chain_reply_to,
"smtp-server=s" => \$smtp_server,
+ "envelope-sender=s" => \$envelope_sender,
"compose" => \$compose,
"quiet" => \$quiet,
"suppress-from" => \$suppress_from,
@@ -445,7 +449,10 @@ sub send_message
my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
$from = "\"$name\"$addr";
}
- my ($author_addr) = ($from =~ /^.*?\s+<(.*?)>/);
+ if(!defined $envelope_sender or -z $envelope_sender) {
+ $from =~ /^.*?\s+<(.*?)>/;
+ $envelope_sender = $1;
+ }
my $header = "From: $from
To: $to
Cc: $cc
@@ -463,9 +470,10 @@ X-Mailer: git-send-email $gitversion
$header .= join("\n", @xh) . "\n";
}
- my @sendmail_args = ('-f',$author_addr,'-i', map { extract_valid_address($_) } @recipients);
+ my @sendmail_args = ('-f',$envelope_sender,'-i', map { extract_valid_address($_) } @recipients);
if ($dry_run) {
# We don't want to send the email.
+ $smtp = !($smtp_server =~ m#^/#);
} elsif ($smtp_server =~ m#^/#) {
my $pid = open my $sm, '|-';
defined $pid or die $!;
@@ -477,7 +485,7 @@ X-Mailer: git-send-email $gitversion
} else {
require Net::SMTP;
$smtp ||= Net::SMTP->new( $smtp_server );
- $smtp->mail( $from ) or die $smtp->message;
+ $smtp->mail( $envelope_sender ) or die $smtp->message;
$smtp->to( @recipients ) or die $smtp->message;
$smtp->data or die $smtp->message;
$smtp->datasend("$header\n$message") or die $smtp->message;
@@ -489,17 +497,15 @@ X-Mailer: git-send-email $gitversion
} else {
print "OK. Log says:\nDate: $date\n";
if ($smtp) {
- print "Server: $smtp_server\n";
+ print "SMTP Server: $smtp_server\n";
+ print "SMTP MAIL FROM: $envelope_sender\n";
+ print "SMTP RCPT TO: ".join(', ',@recipients)."\n";
} else {
print "Sendmail: $smtp_server\n";
- my $s = "";
- foreach my $a (@sendmail_args) {
- $s .= " \'".$a."\'";
- }
- print "Args:$s\n";
+ print "Args: '".join("' '",@sendmail_args)."'\n";
}
print "From: $from\nSubject: $subject\nCc: $cc\nTo: $to\n\n";
- if ($smtp) {
+ if ($smtp and not $dry_run) {
print "Result: ", $smtp->code, ' ',
($smtp->message =~ /\n([^\n]+\n)$/s), "\n";
} else {
@@ -616,7 +622,7 @@ sub cleanup_compose_files() {
}
-$smtp->quit if $smtp;
+$smtp->quit if ($smtp and not $dry_run);
sub unique_email_list(@) {
my %seen;
--
1.5.1
next prev parent reply other threads:[~2007-04-10 22:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-10 22:02 [PATCH] Add sendmail -f support to git-send-email Robin H. Johnson
2007-04-10 22:02 ` Robin H. Johnson [this message]
2007-04-10 22:06 ` Robin H. Johnson
2007-04-10 22:38 ` Frank Lichtenheld
2007-04-10 22:42 ` Robin H. Johnson
2007-04-10 23:00 ` Junio C Hamano
2007-04-11 0:38 ` Frank Lichtenheld
2007-04-11 5:18 ` Junio C Hamano
2007-04-11 8:57 ` Lukas Sandström
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1176242534838-git-send-email-robbat2@gentoo.org \
--to=robbat2@gentoo.org \
--cc=H.Johnson@orbis-terrarum.net \
--cc=Robin@orbis-terrarum.net \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.