gitlab配置邮箱服务

目录


当需要进行 账号注册,创建项目,或合并分支等操作时,可通过邮件通知、邮件验证的方式实现。

1. SMTP服务

用于配置在服务端Gitlab注册用户时的邮件发送确认动作

我使用的是163邮箱,说一下注意点,登录163邮箱,开启“POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务”,并设置授权码;授权码用于下面gitlab配置中的发件箱密码

gitlab配置邮箱服务

2. 服务端配置

$ cat >> /etc/gitlab/gitlab.rb<<EOF
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "发件箱名.163.com"
gitlab_rails['smtp_password'] = "授权码"
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '发件箱名.163.com'
user['git_user_email'] = "发件箱名.163.com"
EOF

3. 更新配置

$ gitlab-ctl stop
$ gitlab-ctl reconfigure
$ gitlab-ctl start

4. 邮件测试

$ gitlab-rails console
Loading production environment (Rails 4.2.10)
irb(main):001:0> Notify.test_email('', '邮件标题', '邮件正文').deliver_now

Notify#test_email: processed outbound mail in 243.5ms

Sent mail to  (365.9ms)
Date: Mon, 10 Dec 2018 16:21:51 +0800
From: GitLab <>
Reply-To: GitLab <>
To: 
....
...
<!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=E4=BB=B6=E6=AD=A3=E6=96=87</p></body></html>

=> #<Mail::Message:70175369260100, Multipart: false, Headers: <Date: Mon, 10 Dec 2018 16:21:51 +0800>, <From: GitLab <>>, <Reply-To: GitLab <>>, <To: >, <Message-ID: <>>, <Subject: 邮件标题>, <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>>

等待半分钟左右,如下图所示,配置完成

gitlab配置邮箱服务


?
[sleepy↓]





?

相关推荐