如何配置gitlab的邮件发送功能

  • Post author:
  • Post category:其他


修改gitlab配置文件

/etc/gitlab/gitlab.rb

找到以下被注释的行,取消注释,并填入用于发送邮件的邮箱账号等参数

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "your smtp server"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "your email username"
gitlab_rails['smtp_password'] = "your email password"
gitlab_rails['smtp_domain'] = "email domain"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true



gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'your email'
gitlab_rails['gitlab_email_display_name'] = 'your email display name'
gitlab_rails['gitlab_email_reply_to'] = 'noreply@your_email_domain'

使配置生效

gitlab-ctl reconfigure

测试邮件配置是否正确

gitlab-rails console

稍微等一会,会出现类似以下的提示信息

-------------------------------------------------------------------------------------

GitLab: 11.10.1 (861fe405571)

GitLab Shell: 9.0.0

PostgreSQL: 9.6.11

-------------------------------------------------------------------------------------

Loading production environment (Rails 5.0.7.2)

irb(main):001:0>

输入以下命令测试发送邮件 (把test@example.com换成你要发送的邮箱)

Notify.test_email('test@example.com','Message Subject','Hello, 2020 !').deliver_now

配置个人账号的通知设置

按项目配置通知

收到的邮件示例

参考:


https://www.cnblogs.com/kazihuo/p/10775363.html


https://docs.gitlab.com/omnibus/settings/smtp.html



版权声明:本文为omage原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。