配置可以参考官方文档https://docs.gitlab.com/omnibus/settings/smtp.html
下面以qq邮箱地址为例
首先需要在qq邮箱里开户pop/smtp服务,并获得授权码
然后修改gitlab的配置文件:/etc/gitlab/gitlab.rb
external_url 'http://192.168.11.230'#改为自己的Ip地址 gitlab_rails['gitlab_email_enabled'] = true gitlab_rails['gitlab_email_from'] = 'xxx@qq.com'#自己的qq邮箱 gitlab_rails['gitlab_email_display_name'] = 'CJSZGitLab'#发邮件时显示的名称 gitlab_rails['gitlab_email_reply_to'] = 'xxx@qq.com'#抄送 gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.qq.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "xxx@qq.com"#自己的qq邮箱 gitlab_rails['smtp_password'] = "xxxxxx"#qq的授权码 gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = 'xxx@qq.com'#自己的qq邮箱 gitlab_rails['smtp_domain'] = "smtp.qq.com"
测试发送邮件:
执行 gitlab-rails console
进入控制台。 然后在控制台提示符后输入下面的命令 发送一封测试邮件:Notify.test_email('收件人邮箱', '邮件标题', '邮件正文').deliver_now