惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
The Last Watchdog
The Last Watchdog
L
Lohrmann on Cybersecurity
P
Proofpoint News Feed
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
S
Schneier on Security
罗磊的独立博客
AWS News Blog
AWS News Blog
S
Securelist
J
Java Code Geeks
月光博客
月光博客
V
Vulnerabilities – Threatpost
博客园 - 【当耐特】
有赞技术团队
有赞技术团队
G
GRAHAM CLULEY
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
The Hacker News
The Hacker News
Know Your Adversary
Know Your Adversary
The GitHub Blog
The GitHub Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Scott Helme
Scott Helme
博客园 - Franky
S
Security Affairs
Cyberwarzone
Cyberwarzone
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Forbes - Security
Forbes - Security
K
Kaspersky official blog
Martin Fowler
Martin Fowler
Schneier on Security
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
宝玉的分享
宝玉的分享
腾讯CDC
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
美团技术团队
MyScale Blog
MyScale Blog
L
LangChain Blog
V
V2EX
N
News | PayPal Newsroom
N
News and Events Feed by Topic
aimingoo的专栏
aimingoo的专栏
Blog — PlanetScale
Blog — PlanetScale
IT之家
IT之家

任峻宏的小站

Debugging Memory Leaks in a Next.js Application Troubleshooting: Resolving Devise Issue in an API-only Application How to Customize a Right-Click Menu in React Using ActionCable and React to Create a Simple Chat App 纪念左耳朵耗子 - 任峻宏的小站 Using SSE to Implement ChatGPT in Rails Refresh Myself - 任峻宏的小站 战痘 - 任峻宏的小站 逆向的能量——生活需要批评者 - 任峻宏的小站 人活着必须要有目标 - 任峻宏的小站 《第一人称单数》读书笔记 - 任峻宏的小站 卸载英雄联盟 - 任峻宏的小站 我的 2021 年总结 - 任峻宏的小站 记我的爷爷 - 任峻宏的小站 Migrate from Webpacker to Vite 从入门到放弃 《人生算法》读书笔记 - 任峻宏的小站 《不拘一格》读书笔记 - 任峻宏的小站 我为什么很少写博客 - 任峻宏的小站 我的2020年总结 - 任峻宏的小站 如何避免冲动消费? - 任峻宏的小站 《不能不去爱的两件事》读书笔记 - 任峻宏的小站 记一次搬家 - 任峻宏的小站 My blog V3.0 has been published! 解决服务器上运行 bundle install 时 killed 的问题 解决内存泄漏记录 - 任峻宏的小站 勿忘初心 - 任峻宏的小站 关于 RSpec 的一点方法总结 - 任峻宏的小站 使用 AJAX 重载部分页面 - 任峻宏的小站 Nginx 添加 SSL 支持 - 任峻宏的小站 Nginx 中进行重定向配置 - 任峻宏的小站 记我的第二次部署 - 任峻宏的小站 写在“毕业”之际 - 任峻宏的小站 JS 简单实现弹出层效果 - 任峻宏的小站 速递易工作总结及感想 - 任峻宏的小站 在 Aliyun ECS 上用 Nginx + Passenger 部署 Rails 应用时安装 Passenger 的问题 [译] Common Rails Idioms that Kill Database Performance Git 常用操作总结 - 任峻宏的小站 [译] Terminal 功夫——方便开发者的实用技巧 - 任峻宏的小站 实例方法与类方法 - 任峻宏的小站 各种报错解决集合 - 任峻宏的小站
解决生产环境不能发送邮件的问题 - 任峻宏的小站
任峻宏 · 2018-01-06 · via 任峻宏的小站

问题描述

使用 smtp 方式、ActionMailer 发送邮件,开发环境能正常发送,同样的配置移植到生产环境就不能发邮件了。控制台信息显示 sent 已成功发送,且无任何报错信息,但邮箱就是没收到邮件。

解决过程

  1. 开发环境能正常发送,说明邮件本身应该没有问题,即邮件视图,发件人地址、用户名密码等;
  2. 换用 QQ 邮箱和 outlook 测试,均不能收到邮件,说明不是接受者邮箱问题;
  3. 测试 smtp 参数,先后修改了 default_url_options, domain, enable_starttls_auto 等参数,都不起作用;
  4. ipV6问题,禁用了ipV6依然不起作用;
  5. 参考https://stackoverflow.com/questions/16040158/rails-mailer-netopentimeout-execution-expired-exception-on-production-serve,排查端口问题,可能是25端口被屏蔽了,换用465端口,但出现 readtimeout 错误
  6. 添加参数 ssl: true 问题解决

这其中还有一个很重要的问题,就是用 deliver_later 看不到任何报错,偶然间换成了 deliver_now 发现有 Net::OpenTimeout 错误才顺藤摸瓜解决了问题。telnet smtp.ym.163.com 25 是不通的,telnet smtp.ym.163.com 465 可以连接。所以很有可能就是服务商屏蔽了25端口导致的这个问题。

部分相关代码

production.rb

config.action_mailer.perform_caching = false
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.ym.163.com',
  port:                  465,
  ssl:                   true,
  user_name:             your_username,
  password:              your_password,
  authentication:       'plain',
  enable_starttls_auto:  true
}