Search code examples
ruby-on-railsrubyemailmail-gem

ruby 'mikel/mail' reply-to field


I'm parsing an email using the below style

message = Mail.new(body)   #where body is the RAW source from the email server
message.subject #=> the subject of the message as a string
message.from #=> shows who the email is from

How would I get a value of the 'reply-to' field if it exists? Can the gem do this?


Solution

  • You want the reply_to method:

    message.reply_to
    # => ["[email protected]"]
    

    If there was no reply-to set, it'll be nil:

    message.reply_to
    # => nil
    

    I'd recommend looking through the RDoc documentation, specifically for the Message object. This will show you all of the methods available on your message instance.