Pass an empty string to disable certificate
verification.
--smtp-domain <str> * The domain name sent to HELO/EHLO handshake
- --smtp-auth <str> * Space-separated list of allowed AUTH mechanisms.
+ --smtp-auth <str> * Space-separated list of allowed AUTH mechanisms, or
+ "none" to disable authentication.
This setting forces to use one of the listed mechanisms.
+ --no-smtp-auth Disable SMTP authentication. Shorthand for
+ `--smtp-auth=none`
--smtp-debug <0|1> * Disable, enable Net::SMTP debug.
--batch-size <int> * send max <int> message per connection.
--identity <str> * Use the sendemail.<id> options.
--to-cmd <str> * Email To: via `<str> \$patch_path`
--cc-cmd <str> * Email Cc: via `<str> \$patch_path`
- --suppress-cc <str> * author, self, sob, cc, cccmd, body, bodycc, all.
+ --suppress-cc <str> * author, self, sob, cc, cccmd, body, bodycc, misc-by, all.
--[no-]cc-cover * Email Cc: addresses in the cover letter.
--[no-]to-cover * Email To: addresses in the cover letter.
--[no-]signed-off-by-cc * Send to Signed-off-by: addresses. Default on.
exit(1);
}
+sub completion_helper {
+ print Git::command('format-patch', '--git-completion-helper');
+ exit(0);
+}
+
# most mail servers generate the Date: header, but not all...
sub format_2822_time {
my ($time) = @_;
$author,$sender,$smtp_authpass,$annotate,$compose,$time);
# Things we either get from config, *or* are overridden on the
# command-line.
-my ($no_cc, $no_to, $no_bcc);
+my ($no_cc, $no_to, $no_bcc, $no_identity);
my (@config_to, @getopt_to);
my (@config_cc, @getopt_cc);
my (@config_bcc, @getopt_bcc);
# Read our sendemail.* config
sub read_config {
- my ($prefix) = @_;
+ my ($configured, $prefix) = @_;
foreach my $setting (keys %config_bool_settings) {
my $target = $config_bool_settings{$setting};
my $v = Git::config_bool(@repo, "$prefix.$setting");
- $$target = $v if defined $v;
+ next unless defined $v;
+ next if $configured->{$setting}++;
+ $$target = $v;
}
foreach my $setting (keys %config_path_settings) {
my $target = $config_path_settings{$setting};
if (ref($target) eq "ARRAY") {
- unless (@$target) {
- my @values = Git::config_path(@repo, "$prefix.$setting");
- @$target = @values if (@values && defined $values[0]);
- }
+ my @values = Git::config_path(@repo, "$prefix.$setting");
+ next unless @values;
+ next if $configured->{$setting}++;
+ @$target = @values;
}
else {
my $v = Git::config_path(@repo, "$prefix.$setting");
- $$target = $v if defined $v;
+ next unless defined $v;
+ next if $configured->{$setting}++;
+ $$target = $v;
}
}
foreach my $setting (keys %config_settings) {
my $target = $config_settings{$setting};
if (ref($target) eq "ARRAY") {
- unless (@$target) {
- my @values = Git::config(@repo, "$prefix.$setting");
- @$target = @values if (@values && defined $values[0]);
- }
+ my @values = Git::config(@repo, "$prefix.$setting");
+ next unless @values;
+ next if $configured->{$setting}++;
+ @$target = @values;
}
else {
my $v = Git::config(@repo, "$prefix.$setting");
- $$target = $v if defined $v;
+ next unless defined $v;
+ next if $configured->{$setting}++;
+ $$target = $v;
}
}
if (!defined $smtp_encryption) {
- my $enc = Git::config(@repo, "$prefix.smtpencryption");
+ my $setting = "$prefix.smtpencryption";
+ my $enc = Git::config(@repo, $setting);
+ return unless defined $enc;
+ return if $configured->{$setting}++;
if (defined $enc) {
$smtp_encryption = $enc;
} elsif (Git::config_bool(@repo, "$prefix.smtpssl")) {
}
}
+# sendemail.identity yields to --identity. We must parse this
+# special-case first before the rest of the config is read.
$identity = Git::config(@repo, "sendemail.identity");
-read_config("sendemail.$identity") if defined $identity;
-read_config("sendemail");
+my $rc = GetOptions(
+ "identity=s" => \$identity,
+ "no-identity" => \$no_identity,
+);
+usage() unless $rc;
+undef $identity if $no_identity;
+
+# Now we know enough to read the config
+{
+ my %configured;
+ read_config(\%configured, "sendemail.$identity") if defined $identity;
+ read_config(\%configured, "sendemail");
+}
# Begin by accumulating all the variables (defined above), that we will end up
# needing, first, from the command line:
my $help;
-my $rc = GetOptions("h" => \$help,
- "dump-aliases" => \$dump_aliases);
+my $git_completion_helper;
+$rc = GetOptions("h" => \$help,
+ "dump-aliases" => \$dump_aliases);
usage() unless $rc;
die __("--dump-aliases incompatible with other options\n")
if !$help and $dump_aliases and @ARGV;
"smtp-debug:i" => \$debug_net_smtp,
"smtp-domain:s" => \$smtp_domain,
"smtp-auth=s" => \$smtp_auth,
- "identity=s" => \$identity,
+ "no-smtp-auth" => sub {$smtp_auth = 'none'},
"annotate!" => \$annotate,
"no-annotate" => sub {$annotate = 0},
"compose" => \$compose,
"no-xmailer" => sub {$use_xmailer = 0},
"batch-size=i" => \$batch_size,
"relogin-delay=i" => \$relogin_delay,
+ "git-completion-helper" => \$git_completion_helper,
);
# Munge any "either config or getopt, not both" variables
my @initial_bcc = @getopt_bcc ? @getopt_bcc : ($no_bcc ? () : @config_bcc);
usage() if $help;
+completion_helper() if $git_completion_helper;
unless ($rc) {
usage();
}
my(%suppress_cc);
if (@suppress_cc) {
foreach my $entry (@suppress_cc) {
+ # Please update $__git_send_email_suppresscc_options
+ # in git-completion.bash when you add new options.
die sprintf(__("Unknown --suppress-cc field: '%s'\n"), $entry)
- unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc)$/;
+ unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc|misc-by)$/;
$suppress_cc{$entry} = 1;
}
}
if ($suppress_cc{'all'}) {
- foreach my $entry (qw (cccmd cc author self sob body bodycc)) {
+ foreach my $entry (qw (cccmd cc author self sob body bodycc misc-by)) {
$suppress_cc{$entry} = 1;
}
delete $suppress_cc{'all'};
$suppress_cc{'sob'} = !$signed_off_by_cc if defined $signed_off_by_cc;
if ($suppress_cc{'body'}) {
- foreach my $entry (qw (sob bodycc)) {
+ foreach my $entry (qw (sob bodycc misc-by)) {
$suppress_cc{$entry} = 1;
}
delete $suppress_cc{'body'};
if ($confirm_unconfigured) {
$confirm = scalar %suppress_cc ? 'compose' : 'auto';
};
+# Please update $__git_send_email_confirm_options in
+# git-completion.bash when you add new options.
die sprintf(__("Unknown --confirm setting: '%s'\n"), $confirm)
unless $confirm =~ /^(?:auto|cc|compose|always|never)/;
if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
$aliases{$1} = [ $2 ];
}}}
+ # Please update _git_config() in git-completion.bash when you
+ # add new MUAs.
);
if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {
# (smtp_user was not specified), and 0 otherwise.
sub smtp_auth_maybe {
- if (!defined $smtp_authuser || $auth) {
+ if (!defined $smtp_authuser || $auth || (defined $smtp_auth && $smtp_auth eq "none")) {
return 1;
}
SSL => 1);
}
}
- else {
+ elsif (!$smtp) {
$smtp_server_port ||= 25;
$smtp ||= Net::SMTP->new($smtp_server,
Hello => $smtp_domain,
$smtp->starttls(ssl_verify_params())
or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr());
}
- $smtp_encryption = '';
# Send EHLO again to receive fresh
# supported commands
$smtp->hello($smtp_domain);
# Now parse the message body
while(<$fh>) {
$message .= $_;
- if (/^(Signed-off-by|Cc): (.*)/i) {
+ if (/^([a-z][a-z-]*-by|Cc): (.*)/i) {
chomp;
my ($what, $c) = ($1, $2);
# strip garbage for the address we'll use:
if ($sc eq $sender) {
next if ($suppress_cc{'self'});
} else {
- next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;
- next if $suppress_cc{'bodycc'} and $what =~ /Cc/i;
+ if ($what =~ /^Signed-off-by$/i) {
+ next if $suppress_cc{'sob'};
+ } elsif ($what =~ /-by$/i) {
+ next if $suppress_cc{'misc-by'};
+ } elsif ($what =~ /Cc/i) {
+ next if $suppress_cc{'bodycc'};
+ }
+ }
+ if ($c !~ /.+@.+|<.+>/) {
+ printf("(body) Ignoring %s from line '%s'\n",
+ $what, $_) unless $quiet;
+ next;
}
push @cc, $c;
printf(__("(body) Adding cc: %s from line '%s'\n"),
my $from = shift;
my $to = shift;
- return $message if ($from eq $to and $from ne '7bit');
+ return ($message, $to) if ($from eq $to and $from ne '7bit');
require MIME::QuotedPrint;
require MIME::Base64;
$message = MIME::Base64::decode($message)
if ($from eq 'base64');
- $to = ($message =~ /.{999,}/) ? 'quoted-printable' : '8bit'
+ $to = ($message =~ /(?:.{999,}|\r)/) ? 'quoted-printable' : '8bit'
if $to eq 'auto';
die __("cannot send message as 7bit")