配置 SMTP 发送邮件配置,使用 163 邮箱。
$ sudo vi /etc/gitlab/gitlab.rb
# Change the external_url to the address your users will type in their browser
external_url 'http://xxhost.com'
#Sending application email via SMTP
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "xxpassword"
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true
发送不成功,·sudo gitlab-ctl tail`检查日志报错如下:
2014-07-11_16:12:08.43945 2014-07-11T16:12:08Z 12595 TID-dxf7c Sidekiq::Extensions::DelayedMailer JID-061604dc558ce8560b273cbe INFO: fail: 0.574 sec
2014-07-11_16:12:08.44955 2014-07-11T16:12:08Z 12595 TID-dxf7c WARN: {"retry"=>true, "queue"=>"default", "class"=>"Sidekiq::Extensions::DelayedMailer", "args"=>["---\n- !ruby/class 'Notify'\n- :project_access_granted_email\n- - 4\n"], "jid"=>"061604dc558ce8560b273cbe", "enqueued_at"=>1405094359.354158, "error_message"=>"553 Mail from must equal authorized user\n", "error_class"=>"Net::SMTPFatalError", "failed_at"=>"2014-07-11 15:59:28 UTC", "retry_count"=>5, "retried_at"=>2014-07-11 16:12:08 UTC}
Google 大法后,错误码对应解释网易服务器 smtp 机器要求身份验证帐号和发信帐号必须一致,如果用户在发送邮件时,身份验证帐号和发件人帐号是不同的,因此拒绝发送。
修改 gitlab.rb,修改发信人和身份验证帐号一致,163 发信 OK。
$ sudo vi /etc/gitlab/gitlab.rb
# Change the external_url to the address your users will type in their browser
external_url 'http://xxhost.com'
#Sending application email via SMTP
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "xxpassword"
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true
##修改gitlab配置的发信人
gitlab_rails['gitlab_email_from'] = "[email protected]"
user["git_user_email"] = "[email protected]"