Daemons,Email and DB

Hey

Here is my code:


#!/usr/bin/env ruby

#You might want to change this
ENV[“RAILS_ENV”] ||= “development”

require File.dirname(FILE) + “/…/…/config/environment”
require “net/pop”

$running = true;
Signal.trap(“TERM”) do
$running = false
end

while($running) do

Net::POP3.start(‘mail.mylittlesecret.co.uk’,110,
test+mylittlesecret.co.uk’,‘password’) do |mail|
unless mail.mails.empty?

   mail.mails.each do |n|
     #some saving goes here e.g.
      #email = Email.new
        #email.from = n.from
        #email.body = n.body
        #email.save
     ActiveRecord::Base.logger << "messages saved\n"
   end
  else
    ActiveRecord::Base.logger << "Error\n"
  end
end

sleep 10

end

Is there a way I can split the email up like this (where the comments
are)? I’ve looked through the Net::pop documentation but I couldnt see
anything about saving to a database, only file based.

Thanks, Red

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs