Gitlab7.0通知邮箱的配置(smtp)

1. 首先是拷贝Gitlab自带的example

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

2. 然后用我们自己的邮箱替换example中的邮箱

?
1
sudo  -u git -H vim config /initializers/smtp_settings .rb

这里提供163和腾讯企业邮箱两种配置方式,注意将下面的123456替换成自己的密码

163:

?
1
2
3
4
5
6
7
8
9
10
11
12
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

腾讯企业邮箱:

?
1
2
3
4
5
6
7
8
9
10
11
12
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:  "wangpeng@scnee.com" ,
     password:  "123456" ,
     domain:  "smtp.qq.com" ,
     authentication: :plain,
     enable_starttls_auto:  true ,
   }
end

3. 修改gitlab.yml

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

将默认邮箱修改为自己的邮箱

163:

?
1
2
3
## Email settings
     # Email address used in the "From" field in mails sent by GitLab
     email_from: wpgit@163.com

腾讯企业邮箱:

?
1
2
3
## Email settings
     # Email address used in the "From" field in mails sent by GitLab
     email_from: wangpeng@scnee.com

4. 修改后。重启gitlab

?
1
sudo  service gitlab restart


注意事项:

1. 不需要修改 config/environments/production.rb,网上的其他文章说要修改这个文件可能是针对老版本的,gitlab7.0不需要修改这个文件(已测试)。

2. 腾讯企业邮箱不能使用其帮助网页上所写的465端口。设置了openssl_verify_mode也没有作用。若有人试验成功,请告知我,谢谢。



gitlab 发邮件时模式显示名称为GitLab,如果要修改方法如下:

You can see the sender function in app/mailers/notify.rb#L30:

# The default email address to send emails from
  def default_sender_address
    address = Mail::Address.new(Gitlab.config.gitlab.email_from)
    address.display_name = "GitLab"
    address
  end

  # Return an email address that displays the name of the sender.
  # Only the displayed name changes; the actual email address is always the same.
  def sender(sender_id)
    if sender = User.find(sender_id)
      address = default_sender_address
      address.display_name = sender.name
      address.format
    end
  end


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值