# Using NET::POP3 and ActionMailer successfully. . .?

**URL:** <https://www.ruby-forum.com/t/using-net-pop3-and-actionmailer-successfully/92294>\
**Category:** Rails\
**Created:** [April 17, 2007, 11:08pm UTC](https://www.ruby-forum.com/t/using-net-pop3-and-actionmailer-successfully/92294 "2007-04-17T23:08:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gberz3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f9ae1b/32.png) [@gberz3](https://www.ruby-forum.com/u/gberz3)\
**Post date:** [April 17, 2007, 11:08pm UTC](https://www.ruby-forum.com/t/using-net-pop3-and-actionmailer-successfully/92294/1 "2007-04-17T23:08:37Z")

</div>

Hi all,

I’ve tried all of the following to get email retrieval, parsing, and  
saving to the DB working properly in rails:

> **[Home Magazine - Swik](https://swik.net)**
>
> Inspiration 5 Easy Ways You Can Turn Future Into Success Katen Doe 20 August 2022 Popular Recent 3 Easy Ways To Make Your iPhone Faster 19 August 2022 Facts About Business That Will Help You Success 23 August 2022 15 Unheard Ways To Achieve Greater...

[http://www.nabble.com/Follow-Up:-Receiving-Inbound-Email-and-Creating-Data-in-Rails-App-t3538384.html](http://www.nabble.com/Follow-Up:-Receiving-Inbound-Email-and-Creating-Data-in-Rails-App-t3538384.html)

> **[decoding email attachments with ActionMailer::Base receive | Plasticx Blog](http://plasti.cx/old/articles/2006/12/30/decoding-email-attachments-with-actionmailer-base-receive)**
>
> There are lots of references that say you can decode images and other media attachements in email using the \*receive\* method of \*ActionMailer::Base\* Ruby On Rai

[http://wiki.rubyonrails.org/rails/pages/HowToReceiveEmailsWithActionMailer](http://wiki.rubyonrails.org/rails/pages/HowToReceiveEmailsWithActionMailer)

[http://www.zakainsworth.com/articles/2006/08/09/receiving-email-in-rails](http://www.zakainsworth.com/articles/2006/08/09/receiving-email-in-rails)

. . .none of them worked 100%. For the most part, I’ve been able to  
retrieve the files and save them in their entirety locally to disk.  
However, if I even think of using ActionMailer to then parse and  
handle the file, things go haywire. I receive “end of file” errors  
and all kinds of other things depending on different ‘tweaks’.

In my mind it should be as simple as the semi-demi-sorta-pseudo-code  
that follows:

class myclass \<\< InheritsFrom  
mail = popchecker(user,pass,server)  
foreach mail do |m|  
#process email and attachments for DB  
#save a copy locally  
end  
end

So, my question is, has anyone here successfully incorporated POP3  
email support into their Rails apps, and if so how?

FYI, I’d rather handle all mail internally; not use something like  
‘getmail’ to pass it from outside.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![gberz3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f9ae1b/32.png) [@gberz3](https://www.ruby-forum.com/u/gberz3)\
**Post date:** [April 18, 2007, 6:19am UTC](https://www.ruby-forum.com/t/using-net-pop3-and-actionmailer-successfully/92294/2 "2007-04-18T06:19:00Z")

</div>

Hi there,

I have incoming email processing as part of my app and though I use  
IMAP for the interface to fetching email I have successfully used POP as  
well. I use backgroundrb for fetching and processing incoming emails.  
I chose IMAP because it allows me to look at the header and decide  
whether or not I’d like to  
fetch the entire message. With POP you have no choice but to just  
download everything serially.

I never thought that trying to hook rails up directly to postfix or  
whatever and having  
it spin up rails on every single incoming email would work very well  
at all so I chose the  
“pull” method instead where I check mail on an interval with  
backgroundrb.

-Michael  
[http://javathehutt.blogspot.com](http://javathehutt.blogspot.com)
