Git GitLab 配置通过 smtp.163.com 发送邮件

sailorhero · 2014年07月12日 · 最后由 odirus 回复于 2015年06月24日 · 114958 次阅读

配置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'] = "xxuser@163.com"
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'] = "xxuser@163.com"
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'] = "xxuser@163.com"
user["git_user_email"] = "xxuser@163.com"
共收到 3 条回复

申请一个mailgun,每月一万封免费邮件

不是有个文件专门配置邮件的吗? config/initializers/smtp_settings.rb.sample

请问楼主,为啥我的邮件配置之后,总是接受不到,但是日志里面显示的是已经发送成功。不知道SMTP有没有debug的方式。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册