【发布时间】:2016-03-03 22:54:22
【问题描述】:
我正在使用 Mailman gem 从我的 rails 应用程序中轮询电子邮件。我关注了 Railcasts here
在那篇 Railscasts 中,Ryan Bates 展示了如何从我们收到的电子邮件中检索主题和内容,我可以照着做。
但是现在,我想从电子邮件中获取另一个属性,更具体地说是 “Reply-To” 属性。那我该怎么做呢?
我试过这样做:message.Reply-to,但我得到了
undefined method `Reply' for #<Mail::Message:0x007fc0fd641890> (NoMethodError)
当我尝试测试它时。以下是完整错误信息的截图:
下面是我的 mailman_server 文件:
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "mailman"
#Mailman.config.logger = Logger.new("log/mailman.log")
Mailman.config.pop3 = {
server: 'pop.gmail.com', port: 995, ssl: true,
username: "xxxxx@gmail.com",
password: "xxxxx"
}
Mailman::Application.run do
default do
puts "Received: #{message.Reply-To}"
end
end
下面是我的 mailman_test.eml 文件:
Date: Fri, 25 February 2016
From: myappsender@gmail.com
Subject: Mailman Test
To: myappsupport@gmail.com
Reply-To: myappreply@gmail.com
【问题讨论】:
-
define: '不工作'
-
@Ecnalyr 我得到了 <:message:0x007fc0fd641890> 的
undefined methodReply' (NoMethodError)` -
你试过按键访问吗?显然
Reply-To不是有效的Ruby 符号。或者,API 可能有一种访问标头的方法。
标签: ruby-on-rails ruby email ruby-on-rails-4 mailman