summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl43
1 files changed, 41 insertions, 2 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 437f8ac46a..cd4b316ddc 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -62,7 +62,7 @@ git send-email --translate-aliases
--smtp-user <str> * Username for SMTP-AUTH.
--smtp-pass <str> * Password for SMTP-AUTH; not necessary.
--smtp-encryption <str> * tls or ssl; anything else disables.
- --smtp-ssl * Deprecated. Use '--smtp-encryption ssl'.
+ --smtp-ssl * Deprecated. Use `--smtp-encryption ssl`.
--smtp-ssl-cert-path <str> * Path to ca-certificates (either directory or file).
Pass an empty string to disable certificate
verification.
@@ -73,6 +73,10 @@ git send-email --translate-aliases
--no-smtp-auth * Disable SMTP authentication. Shorthand for
`--smtp-auth=none`
--smtp-debug <0|1> * Disable, enable Net::SMTP debug.
+ --imap-sent-folder <str> * IMAP folder where a copy of the emails should be sent.
+ Make sure `git imap-send` is set up to use this feature.
+ --[no-]use-imap-only * Only copy emails to the IMAP folder specified by
+ `--imap-sent-folder` instead of actually sending them.
--batch-size <int> * send max <int> message per connection.
--relogin-delay <int> * delay <int> seconds between two successive login.
@@ -200,7 +204,7 @@ my $re_encoded_word = qr/=\?($re_token)\?($re_token)\?($re_encoded_text)\?=/;
# Variables we fill in automatically, or via prompting:
my (@to,@cc,@xh,$envelope_sender,
- $initial_in_reply_to,$reply_to,$initial_subject,@files,
+ $initial_in_reply_to,$reply_to,$initial_subject,@files,@imap_copy,
$author,$sender,$smtp_authpass,$annotate,$compose,$time);
# Things we either get from config, *or* are overridden on the
# command-line.
@@ -277,6 +281,7 @@ my ($smtp_server, $smtp_server_port, @smtp_server_options);
my ($smtp_authuser, $smtp_encryption, $smtp_ssl_cert_path);
my ($batch_size, $relogin_delay);
my ($identity, $aliasfiletype, @alias_files, $smtp_domain, $smtp_auth);
+my ($imap_sent_folder);
my ($confirm);
my (@suppress_cc);
my ($auto_8bit_encoding);
@@ -293,6 +298,7 @@ my $mailmap = 0;
my $target_xfer_encoding = 'auto';
my $forbid_sendmail_variables = 1;
my $outlook_id_fix = 'auto';
+my $use_imap_only = 0;
my %config_bool_settings = (
"thread" => \$thread,
@@ -309,6 +315,7 @@ my %config_bool_settings = (
"forbidsendmailvariables" => \$forbid_sendmail_variables,
"mailmap" => \$mailmap,
"outlookidfix" => \$outlook_id_fix,
+ "useimaponly" => \$use_imap_only,
);
my %config_settings = (
@@ -322,6 +329,7 @@ my %config_settings = (
"smtpauth" => \$smtp_auth,
"smtpbatchsize" => \$batch_size,
"smtprelogindelay" => \$relogin_delay,
+ "imapsentfolder" => \$imap_sent_folder,
"to" => \@config_to,
"tocmd" => \$to_cmd,
"cc" => \@config_cc,
@@ -527,6 +535,8 @@ my %options = (
"smtp-domain:s" => \$smtp_domain,
"smtp-auth=s" => \$smtp_auth,
"no-smtp-auth" => sub {$smtp_auth = 'none'},
+ "imap-sent-folder=s" => \$imap_sent_folder,
+ "use-imap-only!" => \$use_imap_only,
"annotate!" => \$annotate,
"compose" => \$compose,
"quiet" => \$quiet,
@@ -1678,6 +1688,8 @@ EOF
if ($dry_run) {
# We don't want to send the email.
+ } elsif ($use_imap_only) {
+ die __("The destination IMAP folder is not properly defined.") if !defined $imap_sent_folder;
} elsif (defined $sendmail_cmd || file_name_is_absolute($smtp_server)) {
my $pid = open my $sm, '|-';
defined $pid or die $!;
@@ -1829,6 +1841,17 @@ EOF
print "\n";
}
+ if ($imap_sent_folder && !$dry_run) {
+ my $imap_header = $header;
+ if (@initial_bcc) {
+ # Bcc is not a part of $header, so we add it here.
+ # This is only for the IMAP copy, not for the actual email
+ # sent to the recipients.
+ $imap_header .= "Bcc: " . join(", ", @initial_bcc) . "\n";
+ }
+ push @imap_copy, "From git-send-email\n$imap_header\n$message";
+ }
+
return 1;
}
@@ -1931,6 +1954,9 @@ sub pre_process_file {
$in_reply_to = $1;
}
}
+ elsif (/^Reply-To: (.*)/i) {
+ $reply_to = $1;
+ }
elsif (/^References: (.*)/i) {
if (!$initial_in_reply_to || $thread) {
$references = $1;
@@ -2223,6 +2249,19 @@ sub cleanup_compose_files {
$smtp->quit if $smtp;
+if ($imap_sent_folder && @imap_copy && !$dry_run) {
+ my $imap_input = join("\n", @imap_copy);
+ eval {
+ print "\nStarting git imap-send...\n";
+ my ($fh, $ctx) = Git::command_input_pipe(['imap-send', '-f', $imap_sent_folder]);
+ print $fh $imap_input;
+ Git::command_close_pipe($fh, $ctx);
+ 1;
+ } or do {
+ warn "Warning: failed to send messages to IMAP folder $imap_sent_folder: $@";
+ };
+}
+
sub apply_transfer_encoding {
my $message = shift;
my $from = shift;