git+gitlab安装好后邮件默认发出地址是gitlab@localhost ,此地址会被任何邮件服务商都拦截,且没法加入白名单。git
配置gitlab用smtp发送邮件(网上参考大多都不靠谱),最终测试如下三步就能够了:服务器
1. 修改全局配置文件git/.gitconfig文件,这里的email是gitlab发送邮件的Email地址
dom
[user]ide
name = GitLabgitlab
email = gitlab@olymtech.com测试
2. 配置gitlab的发送邮件的SMTP服务加密
修改gitlab/config/environments/production.rb配置文件:url
config.action_mailer.delivery_method= :smtpspa
更改smtp邮件配置文件gitlab/config/initializers/smtp_settings.rb:blog
if Gitlab::Application.config.action_mailer.delivery_method == :smtp
ActionMailer::Base.smtp_settings = {
address: "smtp.exmail.qq.com",
port: 25,
user_name: "gitlab@olymtech.com",
password: "123456",
domain: "mail.qq.com",
authentication: 'plain',
enable_starttls_auto: false
}
end
若是没用smtp没有开加密链接的话 enable_starttls_auto 的值应该配置为 false
3. 须要注意一个问题, 若是你的smtp服务器作了权限限制,只能以登录帐户的邮件账号发邮件的话,还须要修改gitlab/config/gitlab.yml
email_from: gitlab@olymtech.com
support_email: gitlab@olymtech.com
以后发送出来的邮件仍是以gitlab@localhost邮件格式发出,最后 gitlab/config/environments/development.rb在此配置文件中发现这么一段:
# For having correct urls in mails
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
将localhost改为个人发件箱后缀olymtech.com
再次重启gitlab服务,测试邮件OK。
切记开设防火墙的话,本地回环地址必定要开放。
ufw allow from 127.0.0.1