gitlab系统邮箱设置
1、打开gitlab的配置文件
[root@localhost ~]# vim /etc/gitlab/gitlab.rb :
2、修改配置文件,搜索smtp,找下面smtp配置的地方,去掉注释,并做相应的修改,如下:
### GitLab email server settings
###! Docs: https://docs.gitlab.com/omnibus/settings/smtp.html
###! **Use smtp instead of sendmail/postfix.**
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.joy.com" ## 此处要改成你的smtp地址
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "qpmon@joy.com" ## 此处要改成你的邮箱
gitlab_rails['smtp_password'] = "123456" ## 邮箱密码
gitlab_rails['smtp_domain'] = "joy.com" ## smtp地址域名
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
###! **Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert'**
###! Docs: http://api.rubyonrails.org/classes/ActionMailer/Base.html
gitlab_rails['smtp_openssl_verify_mode'] = 'none' # 此处去掉注释,默认none即可
然后再搜索gitlab_email_from,找到如下位置,设置发件人信息,然后保存退出
### Email Settings
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'qpmon@joy.com' ## 发件邮箱
gitlab_rails['gitlab_email_display_name'] = 'git server' ## 显示名字
# gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com'
# gitlab_rails['gitlab_email_subject_suffix'] = ''
3、保存退出修改,执行命令gitlab-ctl reconfigure
重新配置gitlab
[root@localhost ~]# gitlab-ctl reconfigure
4、执行命令gitlab-ctl console
测试发邮件,进入控制台之后执行命令Notify.test_email('guoliang.song@joy.com', 'title', 'content').deliver_now
[root@localhost ~]# gitlab-rails console
------------------------------------------------------------------------------------- GitLab: 12.0.3 (08a51a9db93) GitLab Shell: 9.3.0 PostgreSQL: 10.7 ------------------------------------------------------------------------------------- Loading production environment (Rails 5.1.7) irb(main):001:0> Notify.test_email('你的收件邮箱', '测试邮件标题', '测试邮件正文').deliver_now
图片提示
还有时区要修改一下,默认是UTC区 与中国相差8小时
gitlab_rails['time_zone'] = 'Asia/Shanghai' //改为上海时区
修改邮箱后nginx不能启动的问题
cp /opt/gitlab/embedded/sbin/gitlab-web /opt/gitlab/embedded/sbin/nginx
重新启动GitLab,
gitlab-ctl restart
Comments | NOTHING