# Email not getting deleted on server \[Net::POP3\]

**URL:** <https://www.ruby-forum.com/t/email-not-getting-deleted-on-server-net-pop3/143423>\
**Category:** Rails\
**Created:** [July 18, 2008, 11:32am UTC](https://www.ruby-forum.com/t/email-not-getting-deleted-on-server-net-pop3/143423 "2008-07-18T11:32:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AtsoK](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@AtsoK](https://www.ruby-forum.com/u/AtsoK)\
**Post date:** [July 18, 2008, 11:32am UTC](https://www.ruby-forum.com/t/email-not-getting-deleted-on-server-net-pop3/143423/1 "2008-07-18T11:32:52Z")

</div>

Hello,

I created a rake task to fetch email from Gmail’s server using  
Net::POP3. Everything works, except the messages are not getting  
deleted. Here’s my code:

task :receive =\> :environment do  
require ‘net/pop’  
pop = Net::POP3.new(‘localhost’, 42) # localhost:42 is because of  
stunnel  
pop.start(’[myaddress]’, ‘[mypassword]’)  
unless pop.mails.empty?  
pop.delete\_all do |m|  
StuffMailer.receive(m.pop)  
end  
end  
end

I also changed delete\_all to each\_mail and added “m.delete” after the  
StuffMailer line, which still did not work. I also tried Net::IMAP,  
but I kept getting “unexpected token ATOM (expected SPACE)” errors.

How can I resolve this problem -or- how can I resolve the IMAP error?  
Thank you.
