实现邮件收发功能的详细指南
1. 发送真实世界的邮件
在测试发送真实世界邮件的场景中,我们有如下步骤:
1. 以 “alice@ticketee.com” 身份登录。
2. 进入主页。
3. 点击 “TextMate 2”。
4. 点击 “Release date”。
5. 在 “Text” 字段中输入 “Posting a comment!”。
6. 点击 “Create Comment”。
7. 期望看到 “Comment has been created.”。
8. 使用指定的用户名和密码登录 Gmail。
9. 期望收件箱中有来自 Ticketee 的邮件。
然而,当运行 bin/cucumber features/gmail.feature 时,点击 “Create Comment” 按钮后出现了 Connection refused - connect(2) (Errno::ECONNREFUSED) 错误。这是因为 Action Mailer 默认尝试连接本地运行的 SMTP 服务器,而本地并未运行该服务器。从堆栈跟踪的第一行指向 Ruby 标准库中的 net/smtp.rb 可以判断,现在使用的是 SMTP 协议。
2. 配置 Action Mailer
为了解决上述错误,需要让 Action Mailer 连接到 Gmail 服务器。具体操作如下:
1. 参考 Google 的 “Configuring other mail clients” 页面,获
超级会员免费看
订阅专栏 解锁全文
67

被折叠的 条评论
为什么被折叠?



