joephon / blog

极简博客
3 stars 2 forks source link

How to config email for gitlab setting with alimail #16

Open joephon opened 5 years ago

joephon commented 5 years ago

Dependencies

Step 1 edit gitlab.rb file

sudo vim /srv/gitlab/config/gitlab.rb    #denpens on your config path
### your/config/path/gitlab.rb

### Email Settings
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'git@newteo.com'   # should be as well as gitlab_rails['smtp_user_name']
gitlab_rails['gitlab_email_display_name'] = 'newTeo'
gitlab_rails['gitlab_email_reply_to'] = 'noreply@newteo.com'

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.mxhichina.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "git@newteo.com"
gitlab_rails['smtp_password'] = "[your ali mail password]"
gitlab_rails['smtp_domain'] = "smtp.mxhichina.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['smtp_openssl_verify_mode'] = 'none'

Step 2 save gitlab.rb file and run reconfigure

sudo docker exec gitlab gitlab-ctl reconfigure

Step 3 get in docker image and run some command to test whether email feature is ok or not

sudo docker exec -it gitlab bash   // get in docker image

gitlab-rails console production   // get int rails console

Notify.test_email('your@mail.com', 'Message title', 'Message body').deliver_now   // send test mail

Bingo~

go to check out your mail inbox

这篇文章价值一块钱