Linux-gitlab配置郵箱postfix

gitlab新增新用戶有兩種方式,第一種可以用戶主動注冊(自己設(shè)置密碼);第二種也可以通過root管理員用戶直接添加用戶,發(fā)個郵件到用戶的郵箱里,收到郵件后激活。
如果是第二種方式添加新用戶的話,就需要配置gitlab郵箱了。
相關(guān)環(huán)境
postfix
gitlab

postfix配置

前面一篇已經(jīng)安裝好postfix相關(guān)環(huán)境https://www.cnblogs.com/yoyoketang/p/10272544.html
先輸入systemctl status postfix確定postfix是啟動狀態(tài),看到 Active: active (running)說明,已經(jīng)啟動了

[root@yoyo ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-01-17 10:24:03 CST; 1 day 1h ago
 Main PID: 1629 (master)
   CGroup: /system.slice/postfix.service
           ├─ 1629 /usr/libexec/postfix/master -w
           ├─ 1631 qmgr -l -t unix -u
           └─31352 pickup -l -t unix -u

Jan 18 09:29:37 yoyo postfix/smtp[19300]: 165D54046D: to=<admin@example.com>, relay=none, delay=7...out)
Jan 18 09:39:07 yoyo postfix/qmgr[1631]: 2A0804044C: from=<gitlab@47.104.190.48>, size=7538, nrcp...ive)
Jan 18 09:39:37 yoyo postfix/smtp[20356]: connect to example.com[93.184.216.34]:25: Connection timed out
Jan 18 09:39:37 yoyo postfix/smtp[20356]: 2A0804044C: to=<admin@example.com>, relay=none, delay=8...out)
Jan 18 10:39:07 yoyo postfix/qmgr[1631]: 165D54046D: from=<gitlab@47.104.190.48>, size=7547, nrcp...ive)
Jan 18 10:39:37 yoyo postfix/smtp[26711]: connect to example.com[93.184.216.34]:25: Connection timed out
Jan 18 10:39:37 yoyo postfix/smtp[26711]: 165D54046D: to=<admin@example.com>, relay=none, delay=7...out)
Jan 18 10:49:07 yoyo postfix/qmgr[1631]: 2A0804044C: from=<gitlab@47.104.190.48>, size=7538, nrcp...ive)
Jan 18 10:49:37 yoyo postfix/smtp[27758]: connect to example.com[93.184.216.34]:25: Connection timed out
Jan 18 10:49:37 yoyo postfix/smtp[27758]: 2A0804044C: to=<admin@example.com>, relay=none, delay=8...out)
Hint: Some lines were ellipsized, use -l to show in full.

vim打開gitlab的配置文件:/etc/gitlab/gitlab.rb,新增以下內(nèi)容

  • smtp_addressQQ郵箱服務(wù)器是smtp.qq.com
  • smtp_port端口465 (注意,不要用25端口)
  • smtp_user_name 配置自己的QQ號
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "2833xxx@qq.com"  # 你自己QQ號
gitlab_rails['smtp_password'] = "*************"             # QQ授權(quán)碼
gitlab_rails['smtp_domain'] = "smtp.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '2833xxx@qq.com'   # 你自己QQ號

注意:這里的qq密碼是授權(quán)碼
打開QQ郵箱-設(shè)置-賬戶-帳戶安全-開啟服務(wù)-POP3/SMTP服務(wù)-生成授權(quán)碼-發(fā)個短信

image

配置完成后執(zhí)行g(shù)itlab-ctl reconfigure 讓配置生效

gitlab-ctl reconfigure

測試郵箱

執(zhí)行 gitlab-rails console進入控制臺交互界面, 然后在控制臺提示符后輸入下面內(nèi)容發(fā)送一封測試郵件,測試完成后exit()退出。

gitlab-rails console
Notify.test_email('yoyo_你自己隨便郵箱@qq.com', '郵件標題_test', '郵件正文_test').deliver_now

[root@yoyo gitlab]# gitlab-rails console
Loading production environment (Rails 4.2.8)
irb(main):001:0> Notify.test_email('yoyo_******@qq.com', '郵件標題_test', '郵件正文_test').deliver_now 

Notify#test_email: processed outbound mail in 1.2ms

Sent mail to yoyo_******@qq.com(1375.0ms)
Date: Fri, 18 Jan 2019 13:58:24 +0800
From: GitLab <2833xxx@qq.com>
Reply-To: GitLab <noreply@47.104.190.48>
To: yoyo_******@qq.com
Message-ID: <5c416b00e10ef_3e8f3fe6bd9db11817659@yoyo.mail>
Subject: =?UTF-8?Q?=E9=82=AE=E7=AE=B1=E4=B8=BB=E9=A2=98=5Ftest?=
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Auto-Submitted: auto-generated
X-Auto-Response-Suppress: All

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www=
.w3.org/TR/REC-html40/loose.dtd">
<html><body><p>=E9=82=AE=E7=AE=B1=E6=AD=A3=E6=96=87_test</p></body></html=
>

=> #<Mail::Message:70259829672900, Multipart: false, Headers: <Date: Fri, 18 Jan 2019 13:58:24 +0800>, 
<From: GitLab <2833xxx@qq.com>>, <Reply-To: GitLab <noreply@47.104.190.48>>, 
<To: yoyo_******@qq.com>, <Message-ID: <5c416b00e10ef_3e8f3fe6bd9db11817659@yoyo.mail>>, 
<Subject: 郵箱主題_test>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, 
<Content-Transfer-Encoding: quoted-printable>, 
<Auto-Submitted: auto-generated>, 
<X-Auto-Response-Suppress: All>>
irb(main):006:0> exit()  # 退出

image

新增新賬號

使用root管理員用戶登錄gitlab后臺-> Users ->New user

image

填寫完用戶信息后,點 Crear user按鈕,填的郵箱地址就會收到激活郵件了

image

激動郵箱,設(shè)置登錄密碼,就可以登錄gitlab了

image

新用戶自己注冊

新用戶也可以直接打開gitlab首頁,自己注冊

image
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容