WeAir

GitLab配置SMTP发送邮件

编辑配置文件

首先进入/home/git/gitlab/config/initializers/目录,将该目录下的smtp_settings.rb.sample复制一份并重命名为smtp_settings.rb

1
2
cd /home/git/gitlab/config/initializers
sudo -u git -H cp smtp_settings.rb.sample smtp_settings.rb

编辑smtp_settings.rb文件。

1
sudo -u git -H editor smtp_settings.rb

更改配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if Rails.env.production?
Rails.application.config.action_mailer.delivery_method = :smtp

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: "smtp.yandex.com",
port: 587,
user_name: "gitlab@domain.name",
password: "Password",
domain: "domain.name",
authentication: :login,
enable_starttls_auto: true,
openssl_verify_mode: 'none'
}
end

同时编辑/home/git/gitlab/config/目录下的gitlab.yml文件。

1
2
cd /home/git/gitlab/config/
sudo -u git -H editor gitlab.yml

找到如下配置并更改:

1
2
3
email_from: gitlab@domain.name
email_display_name: GitLab
email_reply_to: gitlab@domain.name

重启GitLab

1
2
3
service gitlab restart
#或
/etc/init.d/gitlab restart