Skip to content

imap-send Git Command Guide

The git imap-send command uploads a mailbox generated by git format-patch to an IMAP drafts folder, enabling patch submission through email clients that cannot read mailbox files directly.

Terminal window
git imap-send [-v] [-q] [--[no-]curl] [(--folder|-f) <folder>]
git imap-send --list
OptionDescription
-v, --verboseEnable verbose output
-q, --quietSuppress output
--curlUse curl for IMAP operations (default)
--no-curlAvoid curl, use alternative methods
-f <folder>Specify IMAP folder (Drafts default)
--listList available IMAP folders
ParameterDescription
<folder>IMAP folder name for draft patches
Terminal window
# Configure IMAP server credentials
git config --global sendemail.smtpserver imap.gmail.com
git config --global sendemail.smtpencryption tls
git config --global sendemail.smtpuser your.email@gmail.com
# Configure IMAP settings (for imap-send)
git config --global imap.host imaps://imap.gmail.com
git config --global imap.user your.email@gmail.com
git config --global imap.pass your-app-password
git config --global imap.folder "[Gmail]/Drafts"
Terminal window
# Generate application-specific password:
# 1. Go to Google Account settings
# 2. Security > 2-Step Verification > App passwords
# 3. Generate password for "Mail"
# 4. Use that password in imap.pass
Terminal window
# Generate patches and upload to IMAP
git format-patch --signoff --stdout origin/master | git imap-send
# Upload specific patches
git format-patch HEAD~3..HEAD --stdout | git imap-send
# Send single patch
git format-patch HEAD~1 --stdout | git imap-send
Terminal window
git config imap.host imaps://imap.gmail.com:993
git config imap.user your.email@gmail.com
git config imap.pass your-app-password
git config imap.folder "[Gmail]/Drafts"
Terminal window
git config imap.host imaps://outlook.office365.com:993
git config imap.user user@company.com
git config imap.pass your-password
git config imap.folder "Drafts"
Terminal window
git config imap.host imaps://mail.example.com:993
git config imap.user developer@example.com
git config imap.pass your-password
git config imap.folder "INBOX.Drafts"
Terminal window
# List available folders
git imap-send --list
# Upload to specific folder
git format-patch --stdout HEAD~1 | git imap-send --folder "Patches"
# Use custom folder
git imap-send -f "[Patches]/Review"
Terminal window
# Create patches for code review
git format-patch --cover-letter --signoff --stdout > patches.mbox
# Upload to IMAP for client access
cat patches.mbox | git imap-send
# Then access via email client to send
#!/bin/bash
# Generate and upload patches automatically
if git format-patch --stdout origin/master > patches.mbox; then
cat patches.mbox | git imap-send -q
echo "Patches uploaded for review"
fi
Terminal window
# Developer creates patches
git format-patch --signoff --cover-letter -n HEAD~5 > patches.mbox
# Upload for team access
cat patches.mbox | git imap-send --verbose
# Notify team
echo "Patches available in email drafts folder"
Terminal window
# Use app passwords instead of main account password
git config imap.pass "16-character-app-password"
# Enable two-factor authentication
# Use app-specific passwords or OAuth tokens
Terminal window
# Ensure encrypted connections
git config imap.sslverify true
git config imap.preconnect "imaps://"
Terminal window
# Limit access to patch folders only
git config imap.folder "INBOX.Patches"
# Use read-only access where possible
Terminal window
# Test IMAP connection
openssl s_client -connect imap.gmail.com:993
# Enable verbose logging
git imap-send --verbose --list
# Debug mode
GIT_IMAP_DEBUG=1 git imap-send --list
Terminal window
# Check credentials
curl -v --url "imaps://imap.gmail.com:993" \
--user "user@gmail.com:app-password" \
--request "LIST \"\" \"*\""
# Test with openssl
openssl s_client -connect imap.gmail.com:993 -crlf
Terminal window
# Validate mailbox format
git format-patch --stdout > test.mbox
git imap-send < test.mbox # Test upload
Terminal window
# Check server capabilities
git imap-send --list | head -10
# Verify folder naming conventions
git imap-send --list | grep -i draft
Terminal window
# Process patches with attachments
git format-patch --attach --stdout | git imap-send
# Handle large patchsets
git format-patch --no-numbered --stdout origin/release | \
split -l 1000 - patch- && \
for part in patch-*; do cat "$part" | git imap-send; done
#!/bin/bash
# Robust upload script
if command -v git >/dev/null && [ -d .git ]; then
git format-patch --stdout --signoff > /tmp/patches.mbox
if cat /tmp/patches.mbox | git imap-send -q 2>/dev/null; then
echo "Patches uploaded successfully"
rm /tmp/patches.mbox
else
echo "Upload failed - check IMAP settings"
exit 1
fi
fi
Terminal window
# Fork main repository
git clone https://github.com/project/repo.git
cd repo
git checkout -b feature-fix
# Make changes and commit
echo "Fix applied" >> CHANGELOG.md
git add CHANGELOG.md
git commit -m "fix: update changelog"
# Generate signed patches
git format-patch --signoff --cover-letter -n origin/master > patches.mbox
# Upload to IMAP for review
cat patches.mbox | git imap-send
echo "Patches available in email drafts - open email client to send"
Terminal window
# Generate formal patches for linux-kernel
git format-patch --subject-prefix="PATCH v5" --to=linux-kernel@vger.kernel.org \
--cc=maintainer@example.com --no-chain-reply-to origin/master
# Upload for review process
cat *.patch | git imap-send -f "Kernel-Patches"
echo "Kernel patches uploaded to drafts folder"
echo "Review and send via email client"

How does imap-send improve email patch workflow?

Section titled “How does imap-send improve email patch workflow?”

Traditional patch emailing requires manual mbox file handling. imap-send uploads patches directly to email drafts, enabling review in comfortable email clients before sending.

Yes, alternatives include git send-email for direct SMTP, or manual attachment of mbox files, or using webmail interfaces after manual copying.

Why does Git need format-patch integration?

Section titled “Why does Git need format-patch integration?”

format-patch creates proper email format with headers (From, Date, Subject) that imap-send preserves when uploading to IMAP folders for client consumption.

App passwords are scoped to specific applications, can be revoked without changing main password, and provide audit trail of application access.

What happens to patches after IMAP upload?

Section titled “What happens to patches after IMAP upload?”

Patches remain as drafts in IMAP folder. User must open email client, review content, and manually send. Provides opportunity for final editing in email client.

Can imap-send handle patches with attachments?

Section titled “Can imap-send handle patches with attachments?”

Yes, preserves attachment information from format-patch —attach. Email clients can properly display and handle attached binary files.

What’s the relationship to git send-email?

Section titled “What’s the relationship to git send-email?”

Both facilitate patch submission: imap-send for email client workflow, send-email for direct SMTP sending. Choose based on comfort with email client vs. command line.

For large changesets, break into smaller series using shorter revision ranges, upload individually, or use summarization techniques to avoid email size limits.

Yes, with proper IMAP credentials and service account setup. Configure CI jobs to generate and upload patches automatically to dedicated folders.

What format fields are required for imap-send?

Section titled “What format fields are required for imap-send?”

Patches must have From, Date, and Subject headers in correct order. format-patch generates this automatically, custom mbox files must comply.

How do I troubleshoot folder access issues?

Section titled “How do I troubleshoot folder access issues?”

Use —list to verify folder existence, check IMAP user permissions, confirm folder naming conventions (some servers require INBOX.Prefix format).

Can imap-send work with corporate email systems?

Section titled “Can imap-send work with corporate email systems?”

Yes, works with Exchange, Office 365, Gmail, and other IMAP-capable systems. Requires IMAP access enabled and app passwords for OAuth-only systems.

What’s the performance impact for large patch uploads?

Section titled “What’s the performance impact for large patch uploads?”

Upload time depends on network speed and patch size. Large patchsets may require several minutes. Use —quiet to reduce output during automated usage.

How do I integrate imap-send with Gerrit review systems?

Section titled “How do I integrate imap-send with Gerrit review systems?”

Upload patches to IMAP drafts, then send via email client configured with Gerrit address. Gerrit processes patches on receipt.

  1. Collaborative Patch Review: Upload patches to shared IMAP folders for team review before submission
  2. Open Source Contributions: Standard workflow for submitting patches to project mailing lists
  3. Corporate Review Processes: Integrate with organizational email systems for code review workflows
  4. Cross-Platform Compatibility: Work with any IMAP-capable email system regardless of Git client availability
  5. Backup and Archival: Maintain patch collections in email system for permanent storage and easy searching
  6. Integration with Email Workflows: Leverage existing email infrastructure for patch management and distribution