如何配置Gitlab在ubuntu上发送电子邮件?

时间:2018-06-10 15:02:55

标签: ubuntu server smtp gitlab

这是我的问题

  • 我在服务器上安装了Gitlab
  • 当我为Gitlab创建新用户时,它必须向新用户邮件地址发送电子邮件以设置新密码
  • 但电子邮件永远不会离开
  • 我应该在我的ovh账户上做些什么吗? (我只是拿了5个电子邮件的域名和mx计划)
  • 我应该使用其他东西吗?

这就是我所做的

  • /etc/gitlab/gitlab.rb

    gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "ssl0.ovh.net" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] ='gitlab@domain.com' gitlab_rails['smtp_password'] ='xxx' gitlab_rails['smtp_domain'] = "ssl0.ovh.net" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'none' gitlab_rails['gitlab_email_from'] = 'gitlab@domain.com' gitlab_rails['gitlab_email_reply_to'] = 'no-reply@domain.com'

然后我跑:

$>gitlab-ctl reconfigure

$>gitlab-rails console
irb(main):001:0> ActionMailer::Base.delivery_method
=> :smtp
irb(main):003:0> Notify.test_email('xxx@gmail.com', `'Message Subject', 'Message Body').deliver_now`
Notify#test_email: processed outbound mail in 690.5ms

Sent mail to xxx@gmail.com (30042.6ms)
Date: Sun, 10 Jun 2018 14:40:16 +0000
From: GitLab <xxx@domain.com>
Reply-To: GitLab <no-reply@domain.com>
To: xxx@gmail.com
Message-ID: <5b1d38507f7f6_43f93fc1ebfdb104528d7@scw-d9ca55.mail>
Subject: Message Subject
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Auto-Submitted: auto-generated
X-Auto-Response-Suppress: All

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><p>Message Body</p></body></html>

Net::OpenTimeout: execution expired
    from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:542:in `initialize'
    from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:542:in `open'
    from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:542:in `tcp_socket'
    from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:552:in `block in do_start'
    from /opt/gitlab/embedded/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
    from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:551:in `do_start'
    from /opt/gitlab/embedded/lib/ruby/2.3.0/net/smtp.rb:521:in `start'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mail-2.7.0/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mail-2.7.0/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mail-2.7.0/lib/mail/message.rb:2160:in `do_delivery'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mail-2.7.0/lib/mail/message.rb:260:in `block in deliver'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/actionmailer-4.2.10/lib/action_mailer/base.rb:543:in `block in deliver_mail'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `block in instrument'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `instrument'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/actionmailer-4.2.10/lib/action_mailer/base.rb:541:in `deliver_mail'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/mail-2.7.0/lib/mail/message.rb:260:in `deliver'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/actionmailer-4.2.10/lib/action_mailer/message_delivery.rb:85:in `deliver_now'
    from (irb):2
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/console.rb:110:in `start'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/console.rb:9:in `start'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:14:in `require'
    from bin/rails:14:in `<main>'

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

关于"how to install and configure SMTP server on ubuntu"

的非常好的教程

然后,您必须使用自己的SMTP配置更改/etc/gitlab/gitlab.rb中gitlab的SMTP配置。