Rails Mail gem finding out recipient

106 Views Asked by At

I collect all Mails from a pop server with Mail.all

 @currentmails = Mail.all
  # Über alle Mails im Postfach Iterieren
  @currentmails.each do | mail |
    puts mail.to
  end

But mail.to doesn't work ... I got this error:

NoMethodError: undefined method `gsub' for ["[email protected]"]:Mail::AddressContainer

Mail Recipient (to) Looks like this:

<To: <[email protected]>>
1

There are 1 best solutions below

0
On BEST ANSWER

mail.to.to_s

is the solution of the problem.