You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Redmine发送测试邮件遇Net::ReadTimeout错误,请求协助解决

Redmine配置Office365 SMTP发送邮件超时问题排查

环境配置详情

Environment:
  Redmine version                5.1.1.stable
  Ruby version                   3.0.2-p107 (2021-07-07) [x86_64-linux-gnu]
  Rails version                  6.1.7.6
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
Redmine settings:
  Redmine theme                  Default
SCM:
  Git                            2.34.1
  Filesystem                     
Redmine plugins:
  no plugin installed

当前SMTP配置文件

配置文件路径:/home/ubuntu/redmine-5.1.1/config/configuration.yml

# specific configuration options for development environment
# that overrides the default ones
production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      #ssl: true
      #tls: true
      enable_starttls_auto: true
      #openssl_verify_mode: 'none'
      address: "smtp.office365.com"
      port: 587
      #domain: "" # Replace with your domain
      authentication: :login
      user_name: "google.com" # Replace with your Office 365 email address
      password: "*******" # Replace with your Office 365 email password 

报错信息

An error occurred while sending mail (Net::ReadTimeout with #<Socket:(closed)>)

已验证项

  • 可通过telnet连通smtp.office365.com 587端口
  • 安全组已开放587端口至任意地址

需调整的SMTP配置操作

  • 修正邮箱账号:当前user_name填写的google.com无效,必须替换为真实的Office365邮箱地址(如xxx@yourdomain.onmicrosoft.com或自定义域名绑定的邮箱)
  • 启用domain配置:取消domain行的注释,填写你的Office365租户域名(如yourdomain.onmicrosoft.com或公司自定义域名)
  • 明确TLS设置:取消tls: true的注释,保持ssl: true注释状态(587端口使用TLS协议)
  • 添加超时参数:在smtp_settings中增加超时配置,避免读取超时:
    open_timeout: 30
    read_timeout: 30
    
  • 确认密码有效性:如果邮箱开启了多因素认证(MFA),需使用应用专用密码而非普通登录密码;未开启MFA则确保密码填写正确
  • 临时验证证书(可选):若服务器无法信任Office365的SSL证书,可临时取消openssl_verify_mode: 'none'的注释(仅测试用,生产环境建议配置系统证书信任)

调整后的参考配置:

production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      #ssl: true
      tls: true
      enable_starttls_auto: true
      #openssl_verify_mode: 'none'
      address: "smtp.office365.com"
      port: 587
      domain: "yourdomain.onmicrosoft.com" # 替换为你的租户域名
      authentication: :login
      user_name: "your-email@yourdomain.onmicrosoft.com" # 替换为真实邮箱
      password: "your-app-password-or-regular-password" # 替换为对应密码
      open_timeout: 30
      read_timeout: 30

内容的提问来源于stack exchange,提问作者Saahil Kambale

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 19:42:58