Gitlab CE不发送电子邮件

Posted

技术标签:

【中文标题】Gitlab CE不发送电子邮件【英文标题】:Gitlab CE not sending email 【发布时间】:2017-04-07 09:54:15 【问题描述】:

我已经在本地 Ubuntu 服务器上设置了 Gitlab CE,我正在尝试使用 Zoho 向用户发送电子邮件。但是,邮件不会发送。即使使用gitlab-rails console 进行测试:

irb(main):003:0> Notify.test_email('destination_email@address.com', 'Message Subject', 'Message Body').deliver_now

我的 SMTP 配置如下:

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.zoho.com"
gitlab_rails['smtp_port'] = 587 # I've also changed to 465, but in vain
gitlab_rails['smtp_authentication'] = "plain"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_user_name'] = "gitlab@mydomain.com"
gitlab_rails['smtp_password'] = "mypassword"
gitlab_rails['smtp_domain'] = "smtp.zoho.com"

并通过电子邮件配置回复:

gitlab_rails['incoming_email_enabled'] = true
gitlab_rails['incoming_email_address'] = "gitlab-incoming+key@domain.com"
gitlab_rails['incoming_email_email'] = "gitlab@domain.com"
gitlab_rails['incoming_email_password'] = "Password"
gitlab_rails['incoming_email_host'] = "imap.zoho.com"
gitlab_rails['incoming_email_port'] = 993
gitlab_rails['incoming_email_ssl'] = true
gitlab_rails['incoming_email_mailbox_name'] = "inbox"
gitlab_rails['incoming_email_idle_timeout'] = 60

有人可以帮我解决这个问题吗?

更新:这是gitlab_rails console中的测试输出

Notify#test_email:在 414.5 毫秒内处理出站邮件

发送邮件到 user@domain.com (65666.5ms) 日期:2016 年 11 月 23 日,星期三 12:47:12 +0100 来自:亚搏体育app 回复:GitLab

收件人:user@domain.com

消息 ID:

主题:测试

Mime 版本:1.0

内容类型:文本/html; 字符集=UTF-8 内容传输编码:7bit

测试

Net::ReadTimeout: Net::ReadTimeout 来自 /opt/gitlab/embedded/lib/ruby/2.3.0/net/protocol.rb:158:in rbuf_fill' from /opt/gitlab/embedded/lib/ruby/2.3.0/net/protocol.rb:136:inreaduntil' 来自 /opt/gitlab/embedded/lib/ruby/2.3.0/net/protocol.rb:146:in readline' from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:946:inrecv_response' 来自 /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:556:in block in do_start' from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:956:incritical' 来自 /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:556:in do_start' from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:521:instart' 来自 /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/mail-2.6.4/lib/mail/network/delivery_methods/smtp.rb:113:in deliver!' from /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/mail-2.6.4/lib/mail/message.rb:2 149:indo_delivery' 来自 /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/mail-2.6.4/lib/mail/message.rb:2 37:in block in deliver' from /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/actionmailer-4.2.7.1/lib/action_ mailer/base.rb:543:inblock in Deliver_mail' 来自 /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active _support/notifications.rb:164:in block in instrument' from /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active _support/notifications/instrumenter.rb:20:ininstrument' 来自 /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active _support/notifications.rb:164:in instrument' from /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/actionmailer-4.2.7.1/lib/action_ mailer/base.rb:541:indeliver_mail' 来自 /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/mail-2.6.4/lib/mail/message.rb:2 37:in deliver' from /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/actionmailer-4.2.7.1/lib/action_ mailer/message_delivery.rb:85:indeliver_now' 来自 (irb):1 来自 /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/railties-4.2.7.1/lib/rails/comma nds/console.rb:110:in start' from /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/railties-4.2.7.1/lib/rails/comma nds/console.rb:9:instart' 来自/opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/railties-4.2.7.1/lib/rails/comma nds/commands_tasks.rb:68:in console' from /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/railties-4.2.7.1/lib/rails/comma nds/commands_tasks.rb:39:inrun_command! 来自 /opt/gitlab/embedded/service/gem/ruby/2.3.0/gems/railties-4.2.7.1/lib/rails/comma nds.rb:17:in <top (required)>' from bin/rails:9:inrequire' 从 bin/rails:9:in `'

【问题讨论】:

没有错误?没有?你试过什么? @pancho018 看看我的更新。谢谢。 @sk001 我面临着完全相同的问题。自从我将 gitlab 更新到 9.1.3 后,它就开始失败了。你能找到解决办法吗? @sk001 你找到解决方案了吗?你修好了吗?谢谢 @Farzan 你解决了你的问题吗?如果是,你是怎么做的?真的谢谢 【参考方案1】:

我设法用这里接受的答案解决了这个问题:ActionMailer "Net::ReadTimeout" when using Delayed Job with Rackspace "emailsrvr.com"

可能是文档中的一些建议设置 (https://docs.gitlab.com/omnibus/settings/smtp.html) 导致了问题。

这些设置对我有用:

gitlab_rails['smtp_address'] = "secure.emailsrvr.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_domain'] = "domain.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_tls'] = true
gitlab_rails['smtp_user_name'] = "no-reply@domain.com"
gitlab_rails['smtp_password'] = "XXX"

gitlab_rails['gitlab_email_from'] = "no-reply@domain.com"
gitlab_rails['gitlab_support_email'] = "support@domain.com"
gitlab_rails['gitlab_email_reply_to'] = "support@domain.com"

【讨论】:

以上是关于Gitlab CE不发送电子邮件的主要内容,如果未能解决你的问题,请参考以下文章

centos7安装gitlab 支持带认证https,开启邮件功能 超级简单.

Gitlab8.5安装后邮件发送不成功的解决过程

Gitlab配置邮件发送服务

GitLab 电子邮件未发送?

无法从 GitLab 发送邮件

GitLab 电子邮件设置:通过另一个邮件服务器发送