Write Net :: IMAP email address for email mikel / mail

I have a problem passing email with the Net::IMAP library to the Mail object defined using mikel/mail gem.

I get mail with:

 data = imap.uid_fetch(1, "BODY[]") 

but how can I put it in the Mail.read agreement later?

 mail = Mail.read(data.to_s) 

seems to get Errno::ENAMETOOLONG: File name too long . He understands the mailbox as a file name.

Any ideas?

+4
source share
1 answer

Mail.read requires a file name. Use Mail.new to initialize a Mail object from an email source.

Also, select RFC822 rather than BODY[] .

 mail = Mail.new(imap.uid_fetch(1, "RFC822")[0].attr["RFC822"]) 
+8
source

All Articles