<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,10 +1,8 @@
-require 'net/imap'
-
 class MailReader &lt; ActionMailer::Base
 
   def receive(email)         
         
-    issue = Issue.new(
+    issue = Issue.create(
         :subject =&gt; email.subject,
         :description =&gt; email.body,
         :priority_id =&gt; 3,
@@ -13,7 +11,6 @@ class MailReader &lt; ActionMailer::Base
         :author_id =&gt; 2,
         :status_id =&gt; 1        
     )
-    issue.save    
     
     if email.has_attachments?
         for attachment in email.attachments        
@@ -27,41 +24,38 @@ class MailReader &lt; ActionMailer::Base
   end
   
   def self.check_mail
-    # Find all of the projects that have enabled the &quot;ticket emailer&quot; plugin
-    @projects = Project.find :all, :include=&gt;:enabled_modules, :conditions=&gt;&quot;enabled_modules.name='ticket_emailer'&quot;
+  
+     begin
+       require 'net/imap'
+     rescue LoadError
+       raise RequiredLibraryNotFoundError.new('NET::Imap could not be loaded')
+     end
 
-    @projects.each do |@@project|
-    
-        email_server = @@project.custom_values.detect {|v| v.custom_field_id == Setting.plugin_redmine_ticket_emailer['email_server'].to_i}        
-        email_server = email_server.value if email_server
-        
-        email_login = @@project.custom_values.detect {|v| v.custom_field_id == Setting.plugin_redmine_ticket_emailer['email_login'].to_i}      
-        email_login = email_login.value if email_login
-        
-        email_password = @@project.custom_values.detect {|v| v.custom_field_id == Setting.plugin_redmine_ticket_emailer['email_password'].to_i}   
-        email_password = email_password.value if email_password
-        
-        email_folder = @@project.custom_values.detect {|v| v.custom_field_id == Setting.plugin_redmine_ticket_emailer['email_folder'].to_i}  
-        email_folder = email_folder.value if email_folder
-        
-        use_ssl = @@project.custom_values.detect {|v| v.custom_field_id == Setting.plugin_redmine_ticket_emailer['use_ssl'].to_i} 
-        use_ssl = use_ssl.value if use_ssl
-        
-        email_port = @@project.custom_values.detect {|v| v.custom_field_id == Setting.plugin_redmine_ticket_emailer['email_port'].to_i}
-        email_port = email_port.value.to_i if email_port
-                
-        imap = Net::IMAP.new(email_server, port=email_port, usessl=use_ssl)
+     @@config_path = (RAILS_ROOT + '/config/emailer.yml')
+     
+     # Cycle through all of the projects created in the yaml file
+     YAML.load_file(@@config_path).keys.each do |project_name|
+     
+        #Find the project based off the name in the YAML if the emailer is enabled in Redmine
+        @@project = Project.find_by_name project_name, :include=&gt;:enabled_modules , :conditions=&gt;&quot;enabled_modules.name='ticket_emailer'&quot;
 
-        imap.login(email_login, email_password)
-        imap.select(email_folder)
-        imap.search(['ALL']).each do |message_id|
-          msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
-          MailReader.receive(msg)          
-          #Mark message as deleted and it will be removed from storage when user session closd
-          imap.store(message_id, &quot;+FLAGS&quot;, [:Deleted])
+        unless @@project.nil?
+            @@config = YAML.load_file(@@config_path)[project_name].symbolize_keys
+                 
+            imap = Net::IMAP.new(@@config[:email_server], port=@@config[:email_port], usessl=@@config[:use_ssl])
+             
+            imap.login(@@config[:email_login], @@config[:email_password])
+            imap.select(@@config[:email_folder])  
+                     
+            imap.search(['ALL']).each do |message_id|
+              msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
+              MailReader.receive(msg)          
+              #Mark message as deleted and it will be removed from storage when user session closd
+              imap.store(message_id, &quot;+FLAGS&quot;, [:Deleted])
+            end
+            # tell server to permanently remove all messages flagged as :Deleted
+            imap.expunge()
         end
-        # tell server to permanently remove all messages flagged as :Deleted
-        imap.expunge()
     end
   end
   
@@ -79,5 +73,25 @@ class MailReader &lt; ActionMailer::Base
     end
     attached
   end
+  
+private
+
+  def connect_to_email
+     begin
+       require 'net/imap'
+     rescue LoadError
+       raise RequiredLibraryNotFoundError.new('NET::Imap could not be loaded')
+     end
+
+     begin
+       @@config_path = (RAILS_ROOT + '/config/emailer.yml')
+       @@config = YAML.load_file(@@config_path)['mindbites'].symbolize_keys
+     end
+             
+     imap = Net::IMAP.new(@@config[:email_server], port=@@config[:email_port], usessl=@@config[:use_ssl])
+     
+     imap.login(@@config[:email_login], @@config[:email_password])
+     imap.select(@@config[:email_folder])  
+  end
 
 end</diff>
      <filename>app/models/mail_reader.rb</filename>
    </modified>
    <modified>
      <diff>@@ -25,18 +25,6 @@ Redmine::Plugin.register :redmine_ticket_emailer do
   author 'Jim Mulholland'
   description 'A plugin to allow users to email tickets to Redmine.'
   version '0.1.0'
-  
-  # The data necessary to log into your email server.
-  # These setting values will be id fields used to map to the
-  # project custom fields that will be set-up to add email
-  # server data on an individual project basis.
-  # For this first rev, I am assuming you have an IMAP server
-  settings :default =&gt; {'email_server' =&gt; 0,
-                        'email_login' =&gt; 0,
-                        'email_password' =&gt; 0,
-                        'use_ssl' =&gt; 0,
-                        'email_port' =&gt; 0,
-                        'email_folder' =&gt; 0}, :partial =&gt; 'settings/settings'
 
   # This plugin adds a project module
   # It can be enabled/disabled at project level (Project settings -&gt; Modules)
@@ -46,6 +34,4 @@ Redmine::Plugin.register :redmine_ticket_emailer do
     permission :view_ticket_emailer, {:ticket_emailer =&gt; :show}
   end
 
-  # A new item is added to the project menu
-  menu :project_menu, 'Emailer Setup', :controller =&gt; 'ticket_emailer', :action =&gt; 'show'
 end</diff>
      <filename>init.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6a78132285f956f48463c574a1d378adc537bea9</id>
    </parent>
  </parents>
  <author>
    <name>Jim Mulholland</name>
    <email>jim@squeejee.com</email>
  </author>
  <url>http://github.com/mully/redmine_ticket_emailer/commit/85635beffb81c2bd7bd723e275357a9395c141b1</url>
  <id>85635beffb81c2bd7bd723e275357a9395c141b1</id>
  <committed-date>2008-03-17T21:31:22-07:00</committed-date>
  <authored-date>2008-03-17T21:31:22-07:00</authored-date>
  <message>Refactored to retrieve email creds via an yaml file instead of saving them to the database via custom fields.</message>
  <tree>ce04ad8ec1ee07c933ee1ce5cc34336de13fd4c5</tree>
  <committer>
    <name>Jim Mulholland</name>
    <email>jim@squeejee.com</email>
  </committer>
</commit>
