實現Git提交後自動郵件通知的功能配置

2021-07-22 13:25:34 字數 2199 閱讀 3527

一、安裝配置msmtp

1 安裝msmtp

wget 

.5/msmtp-1.6

.5.tar

.xztar xvf msmtp-1.6

.5.tar

.xzcd msmtp-1.6

.5./configure –prefix=/usr/local/msmtp

make

make install

2 配置msmtp

cd /usr/local/msmtp

mkdir etc

vim msmtprc

#set default values for all following accounts.

defaults

logfile /usr/local/msmtp/msmtp.log

#the smtp server of provider

account test

#smtp郵件伺服器位址

host mail.btte

.net

#傳送郵件的郵箱

from test@163

.net

auth login

#登陸郵件伺服器的賬號

user test@163

.net

#密碼 password ******xx

退出儲存

為了保護賬號密碼,需要修改配置檔案許可權

chmod

600 msmtprc

3 測試msmtp功能

bin/msmtp [email protected]

just a test for msmtp.

[ctrl+d]

二、安裝配置mutt

yum –y install mutt

vim /etc/muttrc

在檔案末尾新增已下指令

set

from="[email protected]"

set sendmail="/usr/local/msmtp/bin/msmtp"

set use_from=yes

set realname="git-server"

set editor="vim"

儲存退出後便可以測試下msmtp+mutt的配置是否成功:

echo

"hello world" | mutt -s

"test again" [email protected]

檢視郵箱是否正常接收到檔案

三、git庫配置

1 以提供git服務的使用者名稱進入git伺服器,修改庫配置檔案以整合msmtp+mutt環境。

例如,我們這裡要對testing庫進行設定,開發人員在test庫在進行push操作後,便會自動傳送郵件給mailinglist下的指定人員。

su git && cd /home/git/repositories/testing.git

vim config //新增以下配置

[hooks]

mailinglist = [email protected] //設定收件人

sendmail = /usr/local/msmtp/bin/msmtp

envelopesender = [email protected] //設定發件人,跟之前的設定對應

emailprefix = "git push notice: " //郵件主題

emailfrom = "git server"

showrev = "git show -c %s;echo" //郵件內容

chmod a+x post-receiev

2 寫入庫名稱,這樣郵件會自動提示push的庫名稱,如果沒有這一步,則會提示是unamed project

vim description //寫入庫名testing

testing
之後就可以在testing庫中測試。任意push一段**,檢視是否會自動傳送郵件。

GIT PUSH後自動傳送通知郵件

git的郵件通知是通過msmtp和mutt來發信的,所以首先需要配置msmtp和mutt環境 伺服器為ubuntu 16.04 安裝郵件客戶端 sudo apt install msmtp配置檔案為msmtprc,可以直接放在當前使用者目錄下 vim msmtprc 配置如下 defaults ac...

Git 提交後自動發email

當然是通過hooks來實現了,對應post receive,指令碼也是已經隨git core安裝就有了的 usr share doc git core contrib hooks post receive email,不過這個指令碼用到了sendmail,我想好多機器上都沒配這個東東吧,好在有好心人...

簡單實現某D自動打卡並傳送通知郵件

windows作業系統 adbshell1.0.40 pyhon3.7 visual stdio code stable android手機 資料線,並配置環境變數 需要定位螢幕座標 import os import time a0 os.popen adb shell input keyevent...