I am polling emails from my rails application by using Mailman gem. I followed the Railcasts here
In that Railscasts, Ryan Bates showed how to retrieve the Subject and the Content from the email that we received, and I could follow that just fine.
But now, I want to fetch the other attribute from the email, more specifically the "Reply-To" attribute. So how could I do this?
I have tried to do this like this: message.Reply-to
, but I got
undefined method `Reply' for #<Mail::Message:0x007fc0fd641890> (NoMethodError)
when I tried to test it. Below is the screenshot of the full error message:
Below is my mailman_server file:
#!/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
Below is my mailman_test.eml file:
Date: Fri, 25 February 2016
From: myappsender@gmail.com
Subject: Mailman Test
To: myappsupport@gmail.com
Reply-To: myappreply@gmail.com
mailman
gem internally uses Mail::Message
while processing the incoming mail.
So you have access to all the methods of Mail::Message
at your disposal. One of those methods is reply_to
. So you could try message.reply_to
.
Refer to Mail::Message Documentation for more info.