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.
git imap-send Syntax:
Section titled “git imap-send Syntax:”git imap-send [-v] [-q] [--[no-]curl] [(--folder|-f) <folder>]git imap-send --listOptions:
Section titled “Options:”| Option | Description |
|---|---|
-v, --verbose | Enable verbose output |
-q, --quiet | Suppress output |
--curl | Use curl for IMAP operations (default) |
--no-curl | Avoid curl, use alternative methods |
-f <folder> | Specify IMAP folder (Drafts default) |
--list | List available IMAP folders |
Parameters:
Section titled “Parameters:”| Parameter | Description |
|---|---|
<folder> | IMAP folder name for draft patches |
Configuration Setup:
Section titled “Configuration Setup:”IMAP Server Configuration:
Section titled “IMAP Server Configuration:”# Configure IMAP server credentialsgit config --global sendemail.smtpserver imap.gmail.comgit config --global sendemail.smtpencryption tlsgit config --global sendemail.smtpuser your.email@gmail.com
# Configure IMAP settings (for imap-send)git config --global imap.host imaps://imap.gmail.comgit config --global imap.user your.email@gmail.comgit config --global imap.pass your-app-passwordgit config --global imap.folder "[Gmail]/Drafts"App Password Setup (Gmail):
Section titled “App Password Setup (Gmail):”# 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.passUsage Patterns:
Section titled “Usage Patterns:”Basic Patch Upload:
Section titled “Basic Patch Upload:”# Generate patches and upload to IMAPgit format-patch --signoff --stdout origin/master | git imap-send
# Upload specific patchesgit format-patch HEAD~3..HEAD --stdout | git imap-send
# Send single patchgit format-patch HEAD~1 --stdout | git imap-sendConfiguration Examples:
Section titled “Configuration Examples:”Gmail IMAP Setup:
Section titled “Gmail IMAP Setup:”git config imap.host imaps://imap.gmail.com:993git config imap.user your.email@gmail.comgit config imap.pass your-app-passwordgit config imap.folder "[Gmail]/Drafts"Office 365/Outlook:
Section titled “Office 365/Outlook:”git config imap.host imaps://outlook.office365.com:993git config imap.user user@company.comgit config imap.pass your-passwordgit config imap.folder "Drafts"Custom IMAP Server:
Section titled “Custom IMAP Server:”git config imap.host imaps://mail.example.com:993git config imap.user developer@example.comgit config imap.pass your-passwordgit config imap.folder "INBOX.Drafts"Folder Management:
Section titled “Folder Management:”# List available foldersgit imap-send --list
# Upload to specific foldergit format-patch --stdout HEAD~1 | git imap-send --folder "Patches"
# Use custom foldergit imap-send -f "[Patches]/Review"Workflows for Patch Submission:
Section titled “Workflows for Patch Submission:”Review Workflow:
Section titled “Review Workflow:”# Create patches for code reviewgit format-patch --cover-letter --signoff --stdout > patches.mbox
# Upload to IMAP for client accesscat patches.mbox | git imap-send
# Then access via email client to sendContinuous Integration:
Section titled “Continuous Integration:”#!/bin/bash# Generate and upload patches automaticallyif git format-patch --stdout origin/master > patches.mbox; then cat patches.mbox | git imap-send -q echo "Patches uploaded for review"fiCollaborative Workflow:
Section titled “Collaborative Workflow:”# Developer creates patchesgit format-patch --signoff --cover-letter -n HEAD~5 > patches.mbox
# Upload for team accesscat patches.mbox | git imap-send --verbose
# Notify teamecho "Patches available in email drafts folder"Security Considerations:
Section titled “Security Considerations:”Authentication Security:
Section titled “Authentication Security:”# Use app passwords instead of main account passwordgit config imap.pass "16-character-app-password"
# Enable two-factor authentication# Use app-specific passwords or OAuth tokensTransport Security:
Section titled “Transport Security:”# Ensure encrypted connectionsgit config imap.sslverify truegit config imap.preconnect "imaps://"Access Control:
Section titled “Access Control:”# Limit access to patch folders onlygit config imap.folder "INBOX.Patches"
# Use read-only access where possibleTroubleshooting:
Section titled “Troubleshooting:”Connection Issues:
Section titled “Connection Issues:”# Test IMAP connectionopenssl s_client -connect imap.gmail.com:993
# Enable verbose logginggit imap-send --verbose --list
# Debug modeGIT_IMAP_DEBUG=1 git imap-send --listAuthentication Problems:
Section titled “Authentication Problems:”# Check credentialscurl -v --url "imaps://imap.gmail.com:993" \ --user "user@gmail.com:app-password" \ --request "LIST \"\" \"*\""
# Test with opensslopenssl s_client -connect imap.gmail.com:993 -crlfMailbox Format Issues:
Section titled “Mailbox Format Issues:”# Validate mailbox formatgit format-patch --stdout > test.mboxgit imap-send < test.mbox # Test uploadServer Compatibility:
Section titled “Server Compatibility:”# Check server capabilitiesgit imap-send --list | head -10
# Verify folder naming conventionsgit imap-send --list | grep -i draftAdvanced Usage:
Section titled “Advanced Usage:”Custom Mailbox Processing:
Section titled “Custom Mailbox Processing:”# Process patches with attachmentsgit format-patch --attach --stdout | git imap-send
# Handle large patchsetsgit format-patch --no-numbered --stdout origin/release | \ split -l 1000 - patch- && \ for part in patch-*; do cat "$part" | git imap-send; doneError Handling:
Section titled “Error Handling:”#!/bin/bash# Robust upload scriptif 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 fifiReal-world Examples:
Section titled “Real-world Examples:”Open Source Contribution Flow:
Section titled “Open Source Contribution Flow:”# Fork main repositorygit clone https://github.com/project/repo.gitcd repogit checkout -b feature-fix
# Make changes and commitecho "Fix applied" >> CHANGELOG.mdgit add CHANGELOG.mdgit commit -m "fix: update changelog"
# Generate signed patchesgit format-patch --signoff --cover-letter -n origin/master > patches.mbox
# Upload to IMAP for reviewcat patches.mbox | git imap-send
echo "Patches available in email drafts - open email client to send"Kernel Development Workflow:
Section titled “Kernel Development Workflow:”# Generate formal patches for linux-kernelgit 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 processcat *.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.
Can I send patches without IMAP?
Section titled “Can I send patches without IMAP?”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.
How do app passwords improve security?
Section titled “How do app passwords improve security?”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.
How do I handle large patchsets?
Section titled “How do I handle large patchsets?”For large changesets, break into smaller series using shorter revision ranges, upload individually, or use summarization techniques to avoid email size limits.
Can I automate imap-send in CI/CD?
Section titled “Can I automate imap-send in CI/CD?”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.
Applications of the git imap-send command
Section titled “Applications of the git imap-send command”- Collaborative Patch Review: Upload patches to shared IMAP folders for team review before submission
- Open Source Contributions: Standard workflow for submitting patches to project mailing lists
- Corporate Review Processes: Integrate with organizational email systems for code review workflows
- Cross-Platform Compatibility: Work with any IMAP-capable email system regardless of Git client availability
- Backup and Archival: Maintain patch collections in email system for permanent storage and easy searching
- Integration with Email Workflows: Leverage existing email infrastructure for patch management and distribution