From: Aditya Garg Date: Wed, 23 Jul 2025 10:33:49 GMT Subject: [PATCH v4 0/2] send-email: integrate with git imap-send Message-ID: In-Reply-To: <08528f201acc1038ebc5861321395d17516094fd.1753003385.git.gargaditya08@live.com> Hi all This patch series introduces integration of `git send-email` with `git imap-send`. The first patch adds the ability to send a copy of sent emails to an IMAP folder specified by the user, which is useful for email providers that do not support sending a copy of sent emails to the "Sent" folder via SMTP. The second patch allows users to copy emails to an IMAP folder without actually sending them. v2 - Fix indentation in patch for imap-send.c - Minor edits to commit message v3 - Rename imap folder to imap sent folder - Make an error message shorter by removing unecessary details v4 - Fix a bug causing emails to be copied to an IMAP folder even if --dry-run is specified. - Minor edits to commit messages and docs. - Add another patch that enables copying emails to an IMAP folder without actually sending them. Aditya Garg (2): send-email: add ability to send a copy of sent emails to an IMAP folder send-email: enable copying emails to IMAP folder without actually sending them Documentation/config/sendemail.adoc | 2 ++ Documentation/git-send-email.adoc | 25 ++++++++++++++++++ git-send-email.perl | 40 +++++++++++++++++++++++++++-- imap-send.c | 26 +++++++++++++------ 4 files changed, 83 insertions(+), 10 deletions(-) Range-diff against v3: 1: da7cee769f ! 1: 27b5eb33bb send-email: add ability to send a copy of sent emails to an IMAP folder @@ Commit message configuration variable `sendemail.imapfolder` and command line option `--imap-folder` which specifies the IMAP folder to send a copy of the sent emails to. If specified, a copy of the sent emails will be sent - by piping the emails to `git imap-send` command, after the all emails are + by piping the emails to `git imap-send` command, after all emails are sent via SMTP and the SMTP server has been closed. Signed-off-by: Aditya Garg @@ Documentation/git-send-email.adoc: must be used for each option. + IMAP folder of your choice. ++ +This feature requires setting up `git imap-send`. See linkgit:git-imap-send[1] -+to get instructions for the same. ++for instructions. + --batch-size=:: Some email servers (e.g. 'smtp.163.com') limit the number of emails to be @@ git-send-email.perl: sub usage { `--smtp-auth=none` --smtp-debug <0|1> * Disable, enable Net::SMTP debug. + --imap-sent-folder * IMAP folder where a copy of the emails should be sent. -+ Make sure `git imap-send` is setup to use this feature. ++ Make sure `git imap-send` is set up to use this feature. --batch-size * send max message per connection. --relogin-delay * delay seconds between two successive login. @@ git-send-email.perl: sub send_message { print "\n"; } -+ if ($imap_sent_folder) { ++ 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. @@ git-send-email.perl: sub cleanup_compose_files { $smtp->quit if $smtp; -+if ($imap_sent_folder && @imap_copy) { ++if ($imap_sent_folder && @imap_copy && !$dry_run) { + my $imap_input = join("\n", @imap_copy); + eval { + print "\nStarting git imap-send...\n"; -: ---------- > 2: 2ad311502d send-email: enable copying emails to IMAP folder without actually sending them -- 2.50.1.320.g2ad311502d