马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
媒介
这个标题网上办理的帖子很多,根本缘故原由就是设置错误,修改好设置就可以了,我也没有其他的更加新奇的办理办法,之以是再总结一遍只是为了本身同一查找方便,同时把一些差别点记录一下,由于版本和运行情况的差别,大概跟网上的办理方案有一点点差别,先写答案再聊差别吧。
办理方案
- 开启企业微信邮箱(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,等候实验完成
- 使用gitlab测试设置是否乐成
- 实验 gitlab-rails console进入控制台,我的呆板性能较差,多等一会看到下令提示符
- 输入背面面的下令 Notify.test_email('收件人邮箱', '邮件标题', '正文').deliver_now 发送一封测试邮件
- 若乐成过则收到测试邮件,失败则会在控制台体现错误消息,根据错误信息查抄和修改设置即可
遇到的错误
我修改设置的路程也不是一帆风顺的,期间也遇到的了几个错误,都是在 Notify.test_email 测试之后发现有标题,徐徐修改的
域名剖析标题
- 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的参数,有一个external_url 体现gitlab的访问域名,可以设置为 external_url 'http://gitlab.gameup.com',而这个域名也可以在界说容器时通过 --hostname 指定
运行情况
我的Gitlab不是在服务器上直接安装的,而是通过Docker安装的gitlab镜像,服务器是CentOS7体系,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安装的,以是上面的很多下令须要到容器中实验,也就是得先实验 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镜像在当前的网络情况下着实难以下载,不得不借助Github的Actions和阿里云的镜像完成中转,可以使用这个开源项目 举行中转
docker安装
上面说了镜像难装,现实上现在连Docker的安装也须要费点劲,我曾经在AWS上安装过一些Docker镜像,那丝滑的程度真的跟教科誊写的千篇一律,但是在我现在所处的网络注定要一波三折了,CentOS7的体系可以按照下面的步调操纵了。
- # 备份源
- 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
- # 安装必要的一些系统工具
- 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, 发邮件须要设置 smtp 和 email 参数
- smtp_tls 和 smtp_enable_starttls_auto 选项是互斥的,只能选择此中一个设置为 true
- 进入到docker镜像内部的下令为 docker exec -it gitlab /bin/bash
==>> 反爬链接,请勿点击,原地爆炸,概不负责!<<== 他时若遂凌云志,敢笑黄巢不丈夫。伟人可以被人们敬仰,也可以被用来作为登天的蹊径,借他人之成绩,抒发本身之情怀~
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!qidao123.com:ToB企服之家,中国第一个企服评测及软件市场,开放入驻,技术点评得现金 |