mail.delete not working 
Author Message
 mail.delete not working

I'm experimenting with some of Ruby's network modules.  I wrote a short
script to delete unwanted email from my mail server.  The mail.delete
command executes, but the email message is not deleted from the server.  The
code is below.

require 'net/pop'
pop = Net::POP.new('MyMailhost.net')
pop.start('myusername', 'mypassword')
nmail = ndmail = 0

pop.each do |mail|
 nmail += 1
 from = mail.header.split("\r\n").grep(/^From: /).to_s
 stop = %r{spam\.net}
 if (from =~ stop)
  mail.delete
  ndmail += 1
  puts "deleted msg #{from}"
 end
end

puts "#{nmail} messsage(s) read, #{ndmail} deleted"



Tue, 17 Jun 2003 00:50:54 GMT  
 mail.delete not working

R> I'm experimenting with some of Ruby's network modules.  I wrote a short
R> script to delete unwanted email from my mail server.  The mail.delete
R> command executes, but the email message is not deleted from the server.  The
R> code is below.

 See the message  [ruby-talk:7024]
 and its response [ruby-talk:7038]

 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/7024
 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/7038

R> pop.start('myusername', 'mypassword')
[...]
R> pop.each do |mail|

 it's best to use POP3#start with a block

Guy Decoux



Tue, 17 Jun 2003 01:17:52 GMT  
 mail.delete not working

Quote:

> I'm experimenting with some of Ruby's network modules.  I wrote a
> short script to delete unwanted email from my mail server.  The
> mail.delete command executes, but the email message is not deleted
> from the server.  The code is below.

You have to use pop.finish (or even better use the block form of
start) to have the server actually execute the deletes.

Dave



Tue, 17 Jun 2003 01:17:30 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Insert, change, delete with toolbar does not work

2. File Delete does not work in W2000

3. DELETE not working

4. vwnc mailing list not working?

5. * mail server not work on NT through cable modem

6. Win32Forth mailing not working ?

7. * mail server not work on NT through cable modem

8. mail function on RedHat not working

9. mail() not working

10. mail() BCC not working

11. Mail function not working

12. mail forwarding not working on the starship?

 

 
Powered by phpBB® Forum Software