connect to a POP3 server to see if there are any messages available for download : Email POP3 « Network « Ruby






connect to a POP3 server to see if there are any messages available for download


require 'net/pop'

mail_server = Net::POP3.new('mail.mailservernamehere.com')

begin
  mail_server.start('username','password')
  if mail_server.mails.empty?
    puts "No mails"
  else
    puts "#{mail_server.mails.length} mails waiting"
  end
rescue
  puts "Mail error"
end

 








Related examples in the same category

1.Downloading all the mails is as simple as using the pop method for each Net::POPMail object:
2.To delete a mail
3.deletes messages if their subject contains the word "medicines":
4.Sending Mail with SMTP
5.e-mail provider
6.specify port number
7.Send the mail directly to that user