Gitlab “enable_starttls and :tls are mutually exclusive. Set :tls if you‘re on an SMTPS connection.“

Gitlab 关于发送邮件的配置如下(腾讯企业邮箱配置片段):

        gitlab_rails['smtp_enable'] = true
        gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
        gitlab_rails['smtp_port'] = 465
        gitlab_rails['smtp_user_name'] = "[email protected]"
        gitlab_rails['smtp_password'] = "xxxxxxxxxxxxxxxxx"
        gitlab_rails['smtp_authentication'] = "login"
        gitlab_rails['smtp_enable_starttls_auto'] = true
        gitlab_rails['smtp_tls'] = true
        gitlab_rails['gitlab_email_from'] = '[email protected]'
        gitlab_rails['smtp_domain'] = "exmail.qq.com"
        gitlab_rails['gitlab_email_display_name'] = '[email protected]'

以上配置在 Gitlab 15.10 版本以前都是正常使用的,邮件发送一直正常。
后来做了升级,升级之后发现邮件不能发送成功,经查阅资料后将 smtp_enable_starttls_auto 设置为 false 后,重启 gitlab 服务,邮件正常发送成功。

参考资料:https://forum.gitlab.com/t/tls-configuration-for-outgoing-emails-does-not-propagate-resulting-in-no-outgoing-emails-at-all/86546

通过命令行测试邮件发送的方法,可以参考如下方式:

root@326adcd27dab:/# gitlab-rails console
--------------------------------------------------------------------------------
 Ruby:         ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux]
 GitLab:       15.11.3 (332cca52b7e) FOSS
 GitLab Shell: 14.18.0
 PostgreSQL:   13.8
------------------------------------------------------------[ booted in 42.62s ]
Loading production environment (Rails 6.1.7.2)
irb(main):001:0> Notify.test_email('[email protected]','测试gitlab','邮件正文测试内容').deliver_now
Delivered mail [email protected] (3059.9ms)
=> #<Mail::Message:296880, Multipart: false, Headers: <Date: Mon, 12 Jun 2023 02:04:41 +0000>, <From: "[email protected]" <[email protected]>>, <Reply-To: "[email protected]" <[email protected]>>, <To: [email protected]>, <Message-ID: <[email protected]>>, <Subject: 测试gitlab>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>, <Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>>

我解决问题之前测试邮件发送时,输出的错误内容如下:

root@2f6ce0bee2e5:/# gitlab-rails console
--------------------------------------------------------------------------------
 Ruby:         ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux]
 GitLab:       15.11.3 (332cca52b7e) FOSS
 GitLab Shell: 14.18.0
 PostgreSQL:   13.8
------------------------------------------------------------[ booted in 48.03s ]
Loading production environment (Rails 6.1.7.2)
irb(main):001:0> Notify.test_email('[email protected]','测试gitlab','邮件正文测试内容').deliver_now
Delivered mail [email protected] (1.4ms)
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/mail_starttls_patch.rb:60:in `build_smtp_session': :enable_starttls and :tls are mutually exclusive. Set :tls if you're on an SMTPS connection. Set :eARTTLS for secure TLS upgrade. (ArgumentError)

(END)

猜你喜欢

转载自blog.csdn.net/catoop/article/details/131163040
今日推荐