Send source patches with (G Suite) and Thunderbird


Gmail’s web mail client is not suitable for sending code patches, since it doesn’t send the email contents as is. TABs are converted to white spaces, trailing spaces are trimmed.

patch collapsed via web Gmail

So the patch cannot be applied with git am or git apply!

$ git apply < patch.txt
error: patch failed: gdb/ChangeLog:1
error: gdb/ChangeLog: patch does not apply
error: patch failed: gdb/darwin-nat.c:1985
error: gdb/darwin-nat.c: patch does not apply

We have to use an external email client (MUA; Mail User Agent).

Which email client should I use?

TL;DR: Use Mutt if you’re familiar with it, otherwise use Thunderbird.

If you’re sending git patch, use git-send-email(1) with googling “git send-email gmail”. It is the recommended way to send patches to Linux kernel.

In this article, cvs diff, svn diff, or any other unified diff (diff -u) formatted patches are supposed to be sent.

So I my checked out all the clients listed in Linux kernel’s document and git-format-patch(1) man page. My requirements are:

  • Open source
  • Continuously developed; Google changes the Gmail’s IMAP interface several times, so incompatibility in the client should be fixed soon; for instance, in 2019, the password login for IMAP was disabled by default, and the standard authentication was replaced with OAuth
  • Many users send patches with that client; If we encounter a problem, someone has likely already solved it on Stack Overflow

Accordingly with the following google results:

Search keywords GUI or TUI # results as of 2020/03/13
“git am” Mutt TUI 11,800
“git am” Thunderbird GUI 11,600
“git am” Alpine TUI 5,300
“git am” KMail GUI 1,650
“git am” Claws Mail GUI 2,270
“git am” TkRat GUI 252
“git am” Sylpheed GUI 262
“git am” Evolution (run only on Linux) GUI 11,900
“git am” outlook (non open source) GUI 6,690
“git am” apple mail (non open source) GUI 7,850
“git am” “apple mail” (non open source) GUI 101

At first I tried Mutt, which seemed to meet the needs, then faced an error like authentication failed. I discarded mutt right after searching gmail mutt “authentication failed” which didn’t show any useful information to solve it.

Next I tried Thunderbird, and I found out it’s very easy, many people are sending patches with it, and there are many knowledges in the web about sending patches.

Enable Gmail’s IMAP

Enable IMAP in Settings.

enable IMAP in Gmail's Setting

Add account in Thunderbird

FileNewExisting Mail Account…

add Gmail's account on Thunderbird (1)

Enter your name and Gmail ( or G Suite ( email address and press Continue. Leave Password blank.

add Gmail's account on Thunderbird (2)

Press Manual config.

add Gmail's account on Thunderbird (3)

Make sure that Authentication is OAuth2 and press Done.

add Gmail's account on Thunderbird (4 Google OAuth)

add Gmail's account on Thunderbird (5 Google OAuth)

Enter your Google (G Suite) password.

add Gmail's account on Thunderbird (6)

Unfortunately, this time I failed the authentication with the following errors:

  • User name or password invalid
  • Configuration could not be verified ― is the user name or password wrong?

I believe this will fixed soon.

As a workaround I used the password authentication.

Password authentication

Leave the Thunderbird’s setting window open!

First, we have to allow less secure app access for password authentication.

If you’re adding G Suite account (if email address is, not, the G Suite administrator have to allow Control access to less secure apps.

(G Suite) Allow users to manage their access to less secure apps

For both Gmail and G Suite, goto Less secure app access settings and turn on Allow less secure apps. Account can be switched by clicking the icon on the upper right.

turn on: Allow less secure apps

Then on Thunderbird, choose Normal password as Authentication and press Done.

add Gmail's account on Thunderbird (7)

You will see the received emails on Gmail, hooray 🎉

Disable format=flowed

But still Thunderbird trims white spaces! Change the settings following to git-format-patch(1):

  • EditAccount SettingsComposition & Addressing → uncheck Compose messages in HTML format
  • EditPreferencesAdvancedConfig Editor…
    • mail.wrap_long_lines: false
    • mailnews.wraplength: 0
    • mailnews.send_plaintext_flowed: false

Now format=flowed will be removed from email headers:

From: Wataru Ashihara <>
Subject: test
Message-ID: <***>
Date: Mon, 9 Mar 2020 19:48:53 +0900
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
                                       ^^^^^^^^^^^^^^^ this removed!
Content-Language: en-US
Content-Transfer-Encoding: 7bit


and body will be sent AS IS.