diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb
index 7d99a72..004ed28 100644
--- a/app/controllers/settings_controller.rb
+++ b/app/controllers/settings_controller.rb
@@ -40,6 +40,9 @@ class SettingsController < ApplicationController
     @options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
     @deliveries = ActionMailer::Base.perform_deliveries
 
+    @users = User.active.find(:all, :order => :login)
+    @roles = Role.find(:all, :order => :name)
+
     @guessed_host_and_path = request.host_with_port.dup
     @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
   end
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 023e1d6..f9f22b1 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -33,7 +33,7 @@ class MailHandler < ActionMailer::Base
     # Project needs to be overridable if not specified
     @@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project)
     # Status overridable by default
-    @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)    
+    @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
     super email
   end
   
@@ -41,16 +41,104 @@ class MailHandler < ActionMailer::Base
   def receive(email)
     @email = email
     @user = User.active.find_by_mail(email.from.to_a.first.to_s.strip)
-    unless @user
-      # Unknown user => the email is ignored
-      # TODO: ability to create the user's account
-      logger.info "MailHandler: email submitted by unknown user [#{email.from.first}]" if logger && logger.info
-      return false
+    unless @user # create user
+      if Setting.mail_handler_create_users_from_incoming_mails.to_i != 0 # creates a user and assigns him to a project
+        @user = create_user(email)
+        return false unless @user
+        return false unless create_role(@user)
+      elsif Setting.mail_handler_assign_unknown_addresses_to_user.to_i != 0 # use default users, needs :add_issue right on project
+        unless @user = User.find_by_id(Setting.mail_handler_assign_unknown_addresses_to_user.to_i)
+          logger.info "MailHandler: could not find User with id [#{Setting.mail_handler_assign_unknown_addresses_to_user.to_i}] to assign sender #{email.from.first}" if logger && loggger.info
+          return false
+        end
+      else
+        # unknown user and no values specified to handle unknown mails
+        logger.info "MailHandler: email submitted by unknown user [#{email.from.first}] (change Settings in incoming E-Mail tab for default behaviour)" if logger && logger.info
+        return false
+      end
     end
     User.current = @user
     dispatch
   end
-  
+
+
+  protected
+  def target_project
+    # TODO: other ways to specify project:
+    # * parse the email To field
+    # * specific project (eg. Setting.mail_handler_target_project)
+    target = Project.find_by_identifier(get_keyword(:project))
+    raise MissingInformation.new('Unable to determine target project') if target.nil?
+    target
+  end
+
+  # creates a user from email address and sets the status depending on the configured actions
+  def create_user(email)
+    new_user = User.new
+    from_addr = email.header['from'].addrs.first
+    new_user.mail = from_addr.address
+    new_user.admin = false
+    email_user_name = from_addr.local
+    new_user.login = if !User.find_by_login(email_user_name) # set login to the email address without domain or if it exists to the full email
+      email_user_name
+    else
+      new_user.mail
+    end
+    new_user.status = User::STATUS_REGISTERED
+    if from_addr.name
+      names = from_addr.name.split(' ')
+    else
+      names = email_user_name.split('.').map(&:capitalize)
+    end
+    new_user.lastname = names.pop
+    new_user.firstname = names.join(' ')
+    password = Token.generate_token_value(8)
+    new_user.password = password
+    new_user.password_confirmation = password
+
+    case Setting.mail_handler_create_users_from_incoming_mails
+    when '1' || '2'
+      token = Token.new(:user => new_user, :action => "register")
+      Mailer.deliver_register(token) if new_user.save and token.save
+      Mailer.deliver_account_information(new_user, password)
+    when '3'
+      new_user.status = User::STATUS_ACTIVE
+      new_user.last_login_on = Time.now
+      if new_user.save
+        Mailer.deliver_account_information(new_user, password, :notice_account_register_done)
+      else
+        logger.info "could not create user #{new_user}" if logger and logger.info
+        return false
+      end
+    else
+      Mailer.deliver_account_activation_request(new_user)
+      Mailer.deliver_account_information(new_user, password, :notice_account_pending)
+    end
+    return new_user
+  end
+
+  # creates a member on the target_project for the given user with the configured role
+  def create_role(user)
+    # Roles need right for add_issue
+    if Setting.mail_handler_role_to_add_users_to_project.to_i != 0
+      if r = Role.find_by_id(Setting.mail_handler_role_to_add_users_to_project.to_i)
+        member = Member.new(
+          :user_id => user.id,
+          :project_id => self.target_project.id
+        )
+        member.roles << r
+        unless member.save
+          logger.info "could not create Role for user #{user.login} and project #{self.target_project.name}" if logger and logger.info
+          return false
+        end
+      else
+        logger.info "could not assing #{user} to #{self.target_project.name}, missing Role id: #{Setting.mail_handler_role_to_add_users_to_project}" if logger and logger.info
+        return false
+      end
+    end
+    return true
+  end
+
   private
 
   MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@}
@@ -94,7 +182,7 @@ class MailHandler < ActionMailer::Base
     priority = (get_keyword(:priority) && Enumeration.find_by_opt_and_name('IPRI', get_keyword(:priority)))
     status =  (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
 
-    # check permission
+    # check permissions
     raise UnauthorizedAction unless user.allowed_to?(:add_issues, project)
     issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority)
     # check workflow
@@ -117,16 +205,7 @@ class MailHandler < ActionMailer::Base
     logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
     issue
   end
-  
-  def target_project
-    # TODO: other ways to specify project:
-    # * parse the email To field
-    # * specific project (eg. Setting.mail_handler_target_project)
-    target = Project.find_by_identifier(get_keyword(:project))
-    raise MissingInformation.new('Unable to determine target project') if target.nil?
-    target
-  end
-  
+
   # Adds a note to an existing issue
   def receive_issue_reply(issue_id)
     status =  (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
@@ -164,7 +243,7 @@ class MailHandler < ActionMailer::Base
       message = message.root
       if user.allowed_to?(:add_messages, message.project) && !message.locked?
         reply = Message.new(:subject => email.subject.gsub(%r{^.*msg\d+\]}, '').strip,
-                            :content => plain_text_body)
+          :content => plain_text_body)
         reply.author = user
         reply.board = message.board
         message.children << reply
@@ -180,9 +259,9 @@ class MailHandler < ActionMailer::Base
     if email.has_attachments?
       email.attachments.each do |attachment|
         Attachment.create(:container => obj,
-                          :file => attachment,
-                          :author => user,
-                          :content_type => attachment.content_type)
+          :file => attachment,
+          :author => user,
+          :content_type => attachment.content_type)
       end
     end
   end
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 992fd50..1ffb9c5 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -158,12 +158,13 @@ class Mailer < ActionMailer::Base
   # Example:
   #   account_information(user, password) => tmail object
   #   Mailer.deliver_account_information(user, password) => sends account information to the user
-  def account_information(user, password)
+  def account_information(user, password, information = '')
     set_language_if_valid user.language
     recipients user.mail
     subject l(:mail_subject_register, Setting.app_title)
     body :user => user,
          :password => password,
+         :information => information,
          :login_url => url_for(:controller => 'account', :action => 'login')
   end
 
diff --git a/app/models/token.rb b/app/models/token.rb
index a5199c7..0312054 100644
--- a/app/models/token.rb
+++ b/app/models/token.rb
@@ -36,7 +36,7 @@ class Token < ActiveRecord::Base
   end
   
 private
-  def self.generate_token_value
-    ActiveSupport::SecureRandom.hex(20)
+  def self.generate_token_value(length = 40)
+    ActiveSupport::SecureRandom.hex(length)
   end
 end
diff --git a/app/views/mailer/account_information.text.html.rhtml b/app/views/mailer/account_information.text.html.rhtml
index 3b6ab6a..e28f6ff 100644
--- a/app/views/mailer/account_information.text.html.rhtml
+++ b/app/views/mailer/account_information.text.html.rhtml
@@ -1,11 +1,15 @@
 <% if @user.auth_source %>
-<p><%= l(:mail_body_account_information_external, @user.auth_source.name) %></p>
+  <p><%= l(:mail_body_account_information_external, @user.auth_source.name) %></p>
 <% else %>
-<p><%= l(:mail_body_account_information) %>:</p>
-<ul>
+  <p><%= l(:mail_body_account_information) %>:</p>
+  <ul>
     <li><%= l(:field_login) %>: <%= @user.login %></li>
     <li><%= l(:field_password) %>: <%= @password %></li>
-</ul>
+  </ul>
 <% end %>
 
+<% if @information -%>
+  <p><%= l(@information) %></p>
+<% end -%>
+
 <p><%= l(:label_login) %>: <%= auto_link(@login_url) %></p>
diff --git a/app/views/mailer/account_information.text.plain.rhtml b/app/views/mailer/account_information.text.plain.rhtml
index 0a02566..ee403c9 100644
--- a/app/views/mailer/account_information.text.plain.rhtml
+++ b/app/views/mailer/account_information.text.plain.rhtml
@@ -3,4 +3,7 @@
 * <%= l(:field_login) %>: <%= @user.login %>
 * <%= l(:field_password) %>: <%= @password %>
 <% end %>
+<% if @information -%>
+  <%= l(@information) %>
+<% end -%>
 <%= l(:label_login) %>: <%= @login_url %>
diff --git a/app/views/settings/_mail_handler.rhtml b/app/views/settings/_mail_handler.rhtml
index 830b1ba..a478bbe 100644
--- a/app/views/settings/_mail_handler.rhtml
+++ b/app/views/settings/_mail_handler.rhtml
@@ -1,18 +1,47 @@
 <% form_tag({:action => 'edit', :tab => 'mail_handler'}) do %>
 
-<div class="box tabular settings">
-<p><label><%= l(:setting_mail_handler_api_enabled) %></label>
-<%= check_box_tag 'settings[mail_handler_api_enabled]', 1, Setting.mail_handler_api_enabled?,
-                  :onclick => "if (this.checked) { Form.Element.enable('settings_mail_handler_api_key'); } else { Form.Element.disable('settings_mail_handler_api_key'); }" %>
-<%= hidden_field_tag 'settings[mail_handler_api_enabled]', 0 %></p>
+  <div class="box tabular settings">
+    <p><label><%= l(:setting_mail_handler_api_enabled) %></label>
+      <%= check_box_tag 'settings[mail_handler_api_enabled]', 1, Setting.mail_handler_api_enabled?,
+        :onclick => "if (this.checked) { Form.Element.enable('settings_mail_handler_api_key'); } else { Form.Element.disable('settings_mail_handler_api_key'); }" %>
+      <%= hidden_field_tag 'settings[mail_handler_api_enabled]', 0 %></p>
 
-<p><label><%= l(:setting_mail_handler_api_key) %></label>
-<%= text_field_tag 'settings[mail_handler_api_key]', Setting.mail_handler_api_key, 
-                                                     :size => 30,
-                                                     :id => 'settings_mail_handler_api_key',
-                                                     :disabled => !Setting.mail_handler_api_enabled? %>
-<%= link_to_function l(:label_generate_key), "if ($('settings_mail_handler_api_key').disabled == false) { $('settings_mail_handler_api_key').value = randomKey(20) }" %></p>
-</div>
+    <p><label><%= l(:setting_mail_handler_api_key) %></label>
+      <%= text_field_tag 'settings[mail_handler_api_key]', Setting.mail_handler_api_key,
+        :size => 30,
+        :id => 'settings_mail_handler_api_key',
+        :disabled => !Setting.mail_handler_api_enabled? %>
+      <%= link_to_function l(:label_generate_key), "if ($('settings_mail_handler_api_key').disabled == false) { $('settings_mail_handler_api_key').value = randomKey(20) }" %></p>
 
-<%= submit_tag l(:button_save) %>
+    <p>
+      <label><%= l(:setting_mail_handler_create_users_from_incoming_mails) %></label>
+      <%= select_tag 'settings[mail_handler_create_users_from_incoming_mails]',
+        options_for_select( [[l(:label_disabled), "0"],
+          [l(:label_registration_activation_by_email), "1"],
+          [l(:label_registration_manual_activation), "2"],
+          [l(:label_registration_automatic_activation), "3"]
+        ], Setting.mail_handler_create_users_from_incoming_mails ),
+        :onChange => "if (this.options[this.selectedIndex].value == \"0\") { Form.Element.enable('settings_mail_handler_assign_unknown_addresses_to_user'); } else { Form.Element.disable('settings_mail_handler_assign_unknown_addresses_to_user'); }"
+    %>
+    </p>
+
+    <p>
+      <label><%= l(:setting_mail_handler_role_to_add_users_to_project) %></label>
+      <%= select(:settings, :mail_handler_role_to_add_users_to_project, @roles.collect {|p| [ p.name, p.id ] },
+        { :include_blank => true, :selected => Setting.mail_handler_role_to_add_users_to_project.to_i }
+      ) %>
+    </p>
+
+  
+    <p>
+      <label><%= l(:setting_mail_handler_assign_unknown_addresses_to_user) %></label>
+      <%= select(:settings, :mail_handler_assign_unknown_addresses_to_user, @users.collect {|p| [ p.login, p.id ] },
+        { :include_blank => true, :selected => Setting.mail_handler_assign_unknown_addresses_to_user.to_i },
+        { :disabled => Setting.mail_handler_create_users_from_incoming_mails.to_i == 0}
+      ) %>
+    </p>
+
+  </div>
+
+  <%= submit_tag l(:button_save) %>
 <% end %>
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 278586a..7aa04c8 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -304,6 +304,9 @@ de:
   setting_enabled_scm: Aktivierte Versionskontrollsysteme
   setting_mail_handler_api_enabled: Abruf eingehender E-Mails aktivieren
   setting_mail_handler_api_key: API-Schlüssel
+  setting_mail_handler_create_users_from_incoming_mails: Erstelle Benutzer aus eingehenden E-Mails
+  setting_mail_handler_assign_unknown_addresses_to_user: Unbekannte Absender folgendem Benutzer zuordnen
+  setting_mail_handler_role_to_add_users_to_project: Rolle für neue Benutzer
   setting_sequential_project_identifiers: Fortlaufende Projektkennungen generieren
   setting_gravatar_enabled: Gravatar Benutzerbilder benutzen
   setting_diff_max_lines_displayed: Maximale Anzahl anzuzeigender Diff-Zeilen
diff --git a/config/locales/en.yml b/config/locales/en.yml
index cdc505a..739dd68 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -280,6 +280,9 @@ en:
   setting_enabled_scm: Enabled SCM
   setting_mail_handler_api_enabled: Enable WS for incoming emails
   setting_mail_handler_api_key: API key
+  setting_mail_handler_create_users_from_incoming_mails: Create users from incoming E-Mails
+  setting_mail_handler_assign_unknown_addresses_to_user: Assign Unknown addresses to the following User
+  setting_mail_handler_role_to_add_users_to_project: Role for new Users
   setting_sequential_project_identifiers: Generate sequential project identifiers
   setting_gravatar_enabled: Use Gravatar user icons
   setting_diff_max_lines_displayed: Max number of diff lines displayed
diff --git a/config/locales/fi.yml b/config/locales/fi.yml
index b988ef3..242b3f5 100644
--- a/config/locales/fi.yml
+++ b/config/locales/fi.yml
@@ -743,6 +743,9 @@ fi:
   label_generate_key: Luo avain
   setting_mail_handler_api_enabled: Ota käyttöön WS saapuville sähköposteille
   setting_mail_handler_api_key: API avain
+  setting_mail_handler_create_users_from_incoming_mails: Luo automaattisesti uusia käyttäjiä saapuvien sähköpostien perusteella
+  setting_mail_handler_assign_unknown_addresses_to_user: Nimeä tuntemattomasta sähköpostiosoitteesta tulleesta viestistä luodut tehtävät seuraavalle käyttäjälle
+  setting_mail_handler_role_to_add_users_to_project: Uusien käyttäjien rooli
   text_email_delivery_not_configured: "Sähköpostin jakelu ei ole määritelty ja sähköpostimuistutukset eivät ole käytössä.\nKonfiguroi sähköpostipalvelinasetukset (SMTP) config/email.yml tiedostosta ja uudelleenkäynnistä sovellus jotta asetukset astuvat voimaan."
   field_parent_title: Aloitussivu
   label_issue_watchers: Tapahtuman seuraajat
diff --git a/config/settings.yml b/config/settings.yml
index 5d4d6ff..27d1834 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -117,7 +117,13 @@ notified_events:
 mail_handler_api_enabled:
   default: 0
 mail_handler_api_key:
-  default: 
+  default:
+mail_handler_create_users_from_incoming_mails:
+  default: 0
+mail_handler_assign_unknown_addresses_to_user:
+  default: 0
+mail_handler_role_to_add_users_to_project:
+  default: 0
 issue_list_default_columns:
   serialized: true
   default: 
diff --git a/extra/mail_handler/rdm-mailhandler.rb b/extra/mail_handler/rdm-mailhandler.rb
old mode 100644
new mode 100755
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 295b8ae..c14ec89 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -33,7 +33,8 @@ class MailHandlerTest < Test::Unit::TestCase
                    :custom_fields,
                    :custom_fields_trackers,
                    :boards,
-                   :messages
+                   :messages,
+                   :settings
   
   FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler'
   
@@ -197,6 +198,21 @@ class MailHandlerTest < Test::Unit::TestCase
     assert_equal 'This is a html-only email.', issue.description
   end
 
+  def test_should_create_new_user_and_assign_to_project
+    issue = submit_email('ticket_with_new_user.eml')
+    assert issue.is_a?(Issue)
+    assert !issue.new_record?
+    assert_equal issue.subject, 'New ticker from new user'
+    assert_equal 'onlinestore', issue.project.name.downcase
+    assert_equal 'jjins', issue.author.login
+    assert_equal 'jjins@somenet.foo', issue.author.mail
+    creator = User.find_by_login('jjins')
+    assert_not_nil creator
+    member = Member.find(:first, :conditions => {:project_id => issue.project.id, :user_id => creator.id})
+    assert_not_nil member
+    assert_equal 'Reporter', member.role.name
+  end
+
   private
   
   def submit_email(filename, options={})
