def mailboxes(mailboxes_dir = "mailboxes")
results = []
mboxes_dir = File.join(self.directory, mailboxes_dir)
Dir.glob(File.join(mboxes_dir, "*")).each do |entry|
next unless File.directory?(entry)
this_mailboxes_dir, local_part = File.split(entry)
next unless Mailbox.valid_local_part?(local_part)
results << Mailbox.new(local_part, self, mailboxes_dir)
end
primary_hostname = Socket.gethostname
if primary_hostname == self.name
while (user = Etc.getpwent) do
next if user.name == "admin"
next unless user.uid >= 1000
next unless Mailbox.valid_local_part?(user.name)
next unless File.directory?(user.dir)
next if results.any?{|mailbox| mailbox.local_part == user.name}
this_mailbox = Mailbox.new(user.name, self)
this_mailbox.local_user = user
results << this_mailbox
end
Etc.endpwent
end
results
end