在安装gitlab仓库时候创建新用户无法发送邮件。
已经安装postfix
[root@VM_0_14_centos ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2018-10-28 16:08:25 CST; 1h 9min ago
Process: 11426 ExecStop=/usr/sbin/postfix stop (code=exited, status=0/SUCCESS)
Process: 16354 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
Process: 16352 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
Process: 16348 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
Main PID: 16428 (master)
CGroup: /system.slice/postfix.service
├─16428 /usr/libexec/postfix/master -w
├─16429 pickup -l -t unix -u
└─16430 qmgr -l -t unix -u
/etc/gitlab/gitlab.rb下面的配置
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'XX@163.com'
gitlab_rails['gitlab_email_display_name'] = 'Admin'
gitlab_rails['gitlab_email_reply_to'] = 'XX@163.com'
gitlab_rails['gitlab_email_subject_suffix'] = '[gitlab]'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "XX@163.com"
gitlab_rails['smtp_password'] = "XX"
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
user['git_user_email'] = "XX@163.com"
测试发送邮件的错误提示:
Net::OpenTimeout: execution expired
from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:539:in `initialize'
from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:539:in `open'
from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:539:in `tcp_socket'
from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:549:in `block in do_start'
from /opt/gitlab/embedded/lib/ruby/2.4.0/timeout.rb:103:in `timeout'
from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:548:in `do_start'
from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:518:in `start'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.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.4.0/gems/mail-2.7.0/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/mail-2.7.0/lib/mail/message.rb:2160:in `do_delivery'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/mail-2.7.0/lib/mail/message.rb:260:in `block in deliver'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.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.4.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `block in instrument'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/activesupport-4.2.10/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `instrument'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/actionmailer-4.2.10/lib/action_mailer/base.rb:541:in `deliver_mail'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/mail-2.7.0/lib/mail/message.rb:260:in `deliver'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/actionmailer-4.2.10/lib/action_mailer/message_delivery.rb:85:in `deliver_now'
from (irb):1
from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/console.rb:110:in `start'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/console.rb:9:in `start'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:68:in `console'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /opt/gitlab/embedded/lib/ruby/gems/2.4.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>'
防火墙和安全策略已经开放25端口
Oct 28 21:07:46 VM_0_14_centos postfix/smtp[29415]: connect to 163mx01.mxmail.netease.com[220.181.14.141]:25: Connection timed out
Oct 28 21:08:16 VM_0_14_centos postfix/smtp[29415]: connect to 163mx02.mxmail.netease.com[220.181.14.155]:25: Connection timed out
Oct 28 21:08:46 VM_0_14_centos postfix/smtp[29415]: connect to 163mx03.mxmail.netease.com[220.181.14.163]:25: Connection timed out
Oct 28 21:09:16 VM_0_14_centos postfix/smtp[29415]: connect to 163mx02.mxmail.netease.com[220.181.14.154]:25: Connection timed out
Oct 28 21:09:46 VM_0_14_centos postfix/smtp[29415]: connect to 163mx03.mxmail.netease.com[220.181.14.156]:25: Connection timed out
求各路大神解答。
邮件配置的问题。
基本上上因为配置端口和是否使用ssl配置不匹配导致的。
1 使用25端口, 就不要配置ssl相关项目
2 使用465(或者其他),应该将以下设置好