Setting Git for email send

Many communities are using Github nowadays, but some communities still use mailing list based development style. The Linux kernel community would be a good example. In the style, all major communications are made by email only. Patches are submitted to the maintainers and one more open mailing lists as a mail. Reviews are also made as replies to the mail.

Because some email clients can distort the original content for so-called ``rich user experience’’ (e.g., changing tabs to spaces or inserting html code), patch submitting people should aware of it and try to keep their mail content to be plain. This can be awful or even impossible on some mail clients.

Git can help formatting and sending your patch files using SMTP. This post describes how you can use git to send email.

Package Install

If you installed git using the package manager, you should install not only git package, but also git-email package. If you are using apt package manager, simply type $ sudo apt install git-email on the terminal.

SMTP Setting

Then, set smtp server configurations for you. Of course, you should enable the smtp configuration on your mail accout first. If your mail account is ready for the smtp, now you should let git to know how it can access to your mail account using ‘git config’. If you want to use your Gmail account, it will be as below:

$ git config --global sendemail.smtpserver
$ git config --global sendemail.smtpserverport 587
$ git config --global sendemail.smtpencryption tls
$ git config --global sendemail.smtpuser <>

You can also set the mail account password as below, but I will recommend you to not store your password in that way, because it can harm your security.

$ git config --global sendemail.smtppass <your_password>

Send Mail

Sending mail is so easy. You should first save your mail message in a file. This could be patch file, which can also easily formatted using git format-patch. After that, make sure you know who you want your mail to be sent to. Now, just type below command.

$ git send-email --to <recipients> <the file containing your message>

If you have not set your password (again, I recommend you do not save your password), this command will ask your password. Just type it on the prompt. Then, your mail will delivered to the recipients you specified.

For more detail, $ git help send-email.


Summarised how you can send email using Git. Install packages, set SMTP, write your mail in a plain file, and git send-email. That’s it. :)

SeongJae Park
Kernel Development Engineer

SeongJae Park is a programmer who loves to analyze and develop systems.