1. 首先是拷贝Gitlab自带的example
cd /home/git/gitlab sudo -u git -H cp config/initializers/smtp_settings.rb.sample config/initializers/smtp_settings.rb
2. 然后用我们自己的邮箱替换example中的邮箱
sudo -u git -H vim config/initializers/smtp_settings.rb
这里提供163和腾讯企业邮箱两种配置方式,注意将下面的123456替换成自己的密码
163:
if Rails.env.production? Gitlab::Application.config.action_mailer.delivery_method = :smtp ActionMailer::Base.smtp_settings = { address: "smtp.163.com", port: 25, user_name: "wpgitlab", password: "123456", domain: "163.com", authentication: :plain, enable_starttls_auto: true } end
腾讯企业邮箱:
if Rails.env.production? Gitlab::Application.config.action_mailer.delivery_method = :smtp ActionMailer::Base.smtp_settings = { address: "smtp.exmail.qq.com", port: 25, user_name: "[email protected]", password: "123456", domain: "smtp.qq.com", authentication: :plain, enable_starttls_auto: true, } end
3. 修改gitlab.yml
cd /home/git/gitlab sudo -u git -H vim config/gitlab.yml
将默认邮箱修改为自己的邮箱
163:
## Email settings # Email address used in the "From" field in mails sent by GitLab email_from: [email protected]
腾讯企业邮箱:
## Email settings # Email address used in the "From" field in mails sent by GitLab email_from: [email protected]
4. 修改后。重启gitlab
sudo service gitlab restart
注意事项:
1. 不需要修改 config/environments/production.rb,网上的其他文章说要修改这个文件可能是针对老版本的,gitlab7.0不需要修改这个文件(已测试)。
2. 腾讯企业邮箱不能使用其帮助网页上所写的465端口。设置了openssl_verify_mode也没有作用。若有人试验成功,请告知我,谢谢。
Gitlab7.0通知邮箱的配置(smtp)
时间: 2024-11-13 01:14:43