最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Gitlab新建用戶無法收到郵件的問題解決辦法

 更新時間:2024年11月08日 08:38:31   作者:AlbertS  
在配置GitLab郵件服務時,可能因為環(huán)境或版本差異遇到問題,本文就來介紹一下Gitlab新建用戶無法收到郵件的問題解決辦法,感興趣的可以了解一下

前言

這個問題網(wǎng)上解決的帖子很多,根本原因就是配置錯誤,修改好配置就可以了,我也沒有其他的更加新奇的解決辦法,之所以再總結一遍只是為了自己統(tǒng)一查找方便,同時把一些差異點記錄一下,因為版本和運行環(huán)境的不同,可能跟網(wǎng)上的解決方案有一點點差異,先寫答案再聊不同吧。

解決方案

  • 開啟企業(yè)微信郵箱(QQ郵箱、163郵箱亦可)的POP3/SMTP服務,獲取授權碼

  • 修改gitlab的配置文件 /etc/gitlab/gitlab.rb 如下

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "gitlab@gameup.com"
gitlab_rails['smtp_password'] = "授權碼"
gitlab_rails['smtp_domain'] = "exmail.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = false
gitlab_rails['smtp_tls'] = true

gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'gitlab@gameup.com'
gitlab_rails['gitlab_email_display_name'] = 'Gitlab'
  • 重新加載配置生效 gitlab-ctl reconfigure,等待執(zhí)行完成

  • 利用gitlab測試配置是否成功

  • 執(zhí)行 gitlab-rails console進入控制臺,我的機器性能較差,多等一會看到命令提示符
  • 輸入后面面的命令 Notify.test_email('收件人郵箱', '郵件標題', '正文').deliver_now 發(fā)送一封測試郵件
  • 若成功過則收到測試郵件,失敗則會在控制臺顯示錯誤消息,根據(jù)錯誤信息檢查和修改配置即可

遇到的錯誤

我修改配置的旅程也不是一帆風順的,期間也遇到的了幾個錯誤,都是在 Notify.test_email 測試之后發(fā)現(xiàn)有問題,逐步修改的

域名解析問題

Notify.test_email('shz@gamegu.com', 'Test Email', 'This is a test email from GitLab').deliver_now
--------------------------------------------------------------------------------
 Ruby:         ruby 3.2.5 (2024-07-26 revision 31d0f1a2e7) [x86_64-linux]
 GitLab:       17.5.1 (e8dca573167) FOSS
 GitLab Shell: 14.39.0
 PostgreSQL:   14.11
------------------------------------------------------------[ booted in 61.07s ]
Loading production environment (Rails 7.0.8.4)
Delivered mail 67248a5c847e9_6f32fe445660@gitlab.gamegu.com.mail (20023.7ms)
/opt/gitlab/embedded/lib/ruby/3.2.0/socket.rb:231:in getaddrinfo': getaddrinfo: Temporary failure in name resolution (SocketError)
        from /opt/gitlab/embedded/lib/ruby/3.2.0/socket.rb:231:in foreach'
        from /opt/gitlab/embedded/lib/ruby/3.2.0/socket.rb:635:in tcp'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:643:in tcp_socket'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:656:in do_start'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:611:in start'
        from /opt/gitlab/embedded/service/gitlab-rails/config/initializers/mail_starttls_patch.rb:53:in start_smtp_session'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:100:in deliver!'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/message.rb:2145:in do_delivery'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/message.rb:253:in block in deliver'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/actionmailer-7.0.8.4/lib/action_mailer/base.rb:588:in block in deliver_mail'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/activesupport-7.0.8.4/lib/active_support/notifications.rb:206:in block in instrument'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/activesupport-7.0.8.4/lib/active_support/notifications/instrumenter.rb:24:in instrument'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/activesupport-7.0.8.4/lib/active_support/notifications.rb:206:in instrument'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/actionmailer-7.0.8.4/lib/action_mailer/base.rb:586:in deliver_mail'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/message.rb:253:in deliver'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/actionmailer-7.0.8.4/lib/action_mailer/message_delivery.rb:119:in block in deliver_now'
        ... 15 levels...
irb(main):002:0>

解決辦法

修改 /etc/resolv.conf 來指定自己服務器的DNS,通用的可以使用 nameserver 8.8.8.8

郵箱認證問題

/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:1076:in check_response': 501 mail from address must be same as authorization user (Net::SMTPSyntaxError)
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:1044:in getok'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:945:in mailfrom'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:767:in send_message'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp_connection.rb:53:in deliver!'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:101:in block in deliver!'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:612:in start'
        from /opt/gitlab/embedded/service/gitlab-rails/config/initializers/mail_starttls_patch.rb:53:in start_smtp_session'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:100:in deliver!'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/message.rb:2145:in do_delivery'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/message.rb:253:in block in deliver'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/actionmailer-7.0.8.4/lib/action_mailer/base.rb:588:in block in deliver_mail'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/activesupport-7.0.8.4/lib/active_support/notifications.rb:206:in block in instrument'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/activesupport-7.0.8.4/lib/active_support/notifications/instrumenter.rb:24:in instrument'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/activesupport-7.0.8.4/lib/active_support/notifications.rb:206:in instrument'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/actionmailer-7.0.8.4/lib/action_mailer/base.rb:586:in deliver_mail'
        from /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/message.rb:253:in deliver'
        ... 16 levels...

解決方案

smtp 配置中應該填寫正確的郵箱和授權碼,同時 /etc/gitlab/gitlab.rb 中設置 gitlab_rails['gitlab_email_from'] 與 gitlab_rails['smtp_user_name'] 一致

端口配置互斥

gitlab_rails['smtp_tls'] and gitlab_rails['smtp_enable_starttls_auto'] are mutually exclusive. Set one of them to false. SMTP providers usually use port 465 for TLS and port 587 for STARTTLS.

解決方案

這個錯誤表明在 GitLab 的配置文件中同時啟用了 smtp_tls 和 smtp_enable_starttls_auto 選項,但它們是互斥的,只能選擇其中一個設置為 true,如果使用 TLS(通常是端口 465)僅將 smtp_tls 選項設置為 true,如果使用 STARTTLS(通常是端口 587)只能將 smtp_enable_starttls_auto 設置為true。

關于gitlab的參數(shù),有一個external_url 表示gitlab的訪問域名,可以配置為 external_url 'http://gitlab.gameup.com',而這個域名也可以在定義容器時通過 --hostname 指定

運行環(huán)境

我的Gitlab不是在服務器上直接安裝的,而是通過Docker安裝的gitlab鏡像,服務器是CentOS7系統(tǒng),gitlab組件相關版本如下:

Components

GitLab v17.5.1
GitLab Shell 14.39.0
GitLab Workhorse v17.5.1
GitLab API v4
GitLab KAS 17.5.1
Ruby 3.2.5p208
Rails 7.0.8.4
PostgreSQL (main) 14.11
PostgreSQL (ci) 14.11
Redis 7.0.15

正因為我是通過Dokcer安裝的,所以上面的很多命令需要到容器中執(zhí)行,也就是得先執(zhí)行 docker exec -it gitlab /bin/bash

而通過Docker安裝gitlab的命令也列舉一下:

docker run --detach \
  --hostname gitlab.gameup.com \
  --publish 443:443 --publish 80:80 --publish 22:22 \
  --name gitlab \
  --restart always \
  --volume /export/docker/gitlab/config:/etc/gitlab \
  --volume /export/docker/gitlab/logs:/var/log/gitlab \
  --volume /export/docker/gitlab/data:/var/opt/gitlab \
  registry.cn-hangzhou.aliyuncs.com/z5z/gitlab-ce:latest

不要問我這個鏡像名字為什么這樣古怪,那么因為DockerHub鏡像在當前的網(wǎng)絡環(huán)境下實在難以下載,不得不借助Github的Actions和阿里云的鏡像完成中轉,可以利用這個開源項目 進行中轉

docker安裝

上面說了鏡像難裝,實際上現(xiàn)在連Docker的安裝也需要費點勁,我曾經(jīng)在AWS上安裝過一些Docker鏡像,那絲滑的程度真的跟教科書寫的一模一樣,但是在我目前所處的網(wǎng)絡注定要一波三折了,CentOS7的系統(tǒng)可以按照下面的步驟操作了。

# 備份源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
# yum使用阿里云
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sudo yum makecache

# 安裝必要的一些系統(tǒng)工具
sudo yum install -y wget yum-utils device-mapper-persistent-data lvm2
# 添加軟件源信息
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 修改源
sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo

# 更新并安裝Docker-CE
sudo yum makecache fast
sudo yum -y install docker-ce
# 開啟Docker服務
sudo systemctl start docker

總結

  • gitlab的配置文件為 /etc/gitlab/gitlab.rb, 發(fā)郵件需要配置 smtp 和 email 參數(shù)
  • smtp_tls 和 smtp_enable_starttls_auto 選項是互斥的,只能選擇其中一個設置為 true
  • 進入到docker鏡像內(nèi)部的命令為 docker exec -it gitlab /bin/bash

 到此這篇關于Gitlab新建用戶無法收到郵件的問題解決辦法的文章就介紹到這了,更多相關Gitlab新建用戶無法收到郵件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • AES加密算法的原理詳解與實現(xiàn)分析

    AES加密算法的原理詳解與實現(xiàn)分析

    這篇文章主要介紹了高級加密標準(AES,Advanced Encryption Standard)為最常見的對稱加密算法(微信小程序加密傳輸就是用這個加密算法的)。對稱加密算法也就是加密和解密用相同的密鑰,需要的朋友可以參考下
    2020-08-08
  • SpringSecurity框架簡介及與shiro特點對比

    SpringSecurity框架簡介及與shiro特點對比

    這篇文章是SpringSecurity框架的入門篇,主要為大家介紹了SpringSecurity框架簡介及與shiro優(yōu)缺點對比有需要的朋友可以借鑒參考下,希望能夠有所幫助
    2022-03-03
  • git設置用戶名密碼的示例代碼

    git設置用戶名密碼的示例代碼

    這篇文章主要介紹了git設置用戶名密碼的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-07-07
  • 如何使用git reset進行多commit合并

    如何使用git reset進行多commit合并

    這篇文章主要介紹了如何使用git reset進行多commit合并問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-04-04
  • kafka安裝過程與可視化工具kafka-eagle

    kafka安裝過程與可視化工具kafka-eagle

    這篇文章主要介紹了安裝kafka與可視化工具kafka-eagle,在本篇文中,我們詳細地教你如何安裝kafka,還有它的可視化工具?kafka-eagle,中間也列舉了一些異常以及它的處理方式,真正做到了手把手教學,需要的朋友可以參考下
    2023-11-11
  • 詳解Google Protobuf簡明教程

    詳解Google Protobuf簡明教程

    這篇文章主要介紹了詳解Google Protobuf簡明教程,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-02-02
  • Wireshark中的http協(xié)議包通訊分析

    Wireshark中的http協(xié)議包通訊分析

    這篇文章主要為大家介紹了Wireshark中的http協(xié)議包通訊分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-12-12
  • vscode使用restClient實現(xiàn)各種http請求的操作方法

    vscode使用restClient實現(xiàn)各種http請求的操作方法

    這篇文章主要介紹了vscode使用restClient實現(xiàn)各種http請求的操作方法,定義變量以及使用環(huán)境變量和返回數(shù)據(jù)作為變量的操作代碼,感興趣的朋友跟隨小編一起看看吧
    2024-02-02
  • 詳解Visual Studio中Git的簡單使用

    詳解Visual Studio中Git的簡單使用

    這篇文章主要介紹了Visual Studio中Git的簡單使用,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-11-11
  • 解決IDEA中編輯HTML格式文件不自動縮進問題

    解決IDEA中編輯HTML格式文件不自動縮進問題

    這篇文章主要介紹了解決IDEA中編輯HTML格式文件不自動縮進問題,本文內(nèi)容簡短,解決方法給大家提出了,需要的朋友可以參考下
    2020-01-01

最新評論

贺兰县| 冷水江市| 太白县| 惠东县| 西宁市| 汝城县| 聂荣县| 平阴县| 宜丰县| 开封县| 赤壁市| 渝北区| 灵台县| 措美县| 徐汇区| 凌云县| 广德县| 共和县| 夏河县| 白河县| 绥滨县| 灌阳县| 右玉县| 铁岭县| 闻喜县| 太保市| 阳西县| 东平县| 双鸭山市| 安庆市| 留坝县| 缙云县| 台北县| 马龙县| 平邑县| 辽源市| 秦安县| 鄂尔多斯市| 洞头县| 深水埗区| 临洮县|