[Git] Configure git email reminder function

This article uses msmtp+mutt+post-receive to build the git email notification function, and the operating system environment is ubuntu10.04.

Step 1: Install and configure msmtp

a. Install msmtp

$ sudo apt-get install msmtp

b. Configure msmtp

$ sudo vi /etc/msmtprc

defaults
account shihaijun
host smtp.exmail.qq.com
from [email protected]
auth login
user [email protected]
password shihaijun123
tls off
account default : shihaijun
logfile /var/log/msmtp.log

Save and exit vim.

View the configuration of msmtp: $msmtp -P

 

Step 2: Install and configure mutt

a. Install mutt

$sudo apt-get install mutt

b. Configure mutt

$ sudo vi / etc / Muttrc

Add the following at the end of the file

# for add Muttr by shihaijun
set sendmail="/usr/bin/msmtp"
set realname="Data Report"
set editor="vi"
set [email protected]
set envelope_from=yes

 Save and exit.

Step 3: Download post-receive (see attachment)

Enter the server repository where you want to add email notifications, as shown in the repo-list.

Copy the post-receive to the hooks directory of the repository, as shown in the hooks-dir.

And increase the execution permission of post-receive with the following command:

$sudo chmod a+x post-receive

 

Step 4: Configure git config

Enter the warehouse and edit the config.

$sudo vi config

Add the field [hooks] as follows:

[hooks]
        sendmail=/usr/bin/msmtp
        emailprefix = "[GIT NOTICE]"
        showrev = "git show -c %s;echo"
        mailinglist = [email protected]
        envelopesender = [email protected]

 

At this point, when the git push action is performed on the client, an email notification will be sent.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327037311&siteId=291194637