diff options
Diffstat (limited to 'app/models/mail_handler.rb')
-rw-r--r-- | app/models/mail_handler.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index 8686c6b01..23a51d83a 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -41,7 +41,13 @@ class MailHandler < ActionMailer::Base # Returns the created object (eg. an issue, a message) or false def receive(email) @email = email - @user = User.find_by_mail(email.from.to_a.first.to_s.strip) + sender_email = email.from.to_a.first.to_s.strip + # Ignore emails received from the application emission address to avoid hell cycles + if sender_email.downcase == Setting.mail_from.to_s.strip.downcase + logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]" if logger && logger.info + return false + end + @user = User.find_by_mail(sender_email) if @user && !@user.active? logger.info "MailHandler: ignoring email from non-active user [#{@user.login}]" if logger && logger.info return false @@ -57,12 +63,12 @@ class MailHandler < ActionMailer::Base logger.info "MailHandler: [#{@user.login}] account created" if logger && logger.info Mailer.deliver_account_information(@user, @user.password) else - logger.error "MailHandler: could not create account for [#{email.from.first}]" if logger && logger.error + logger.error "MailHandler: could not create account for [#{sender_email}]" if logger && logger.error return false end else # Default behaviour, emails from unknown users are ignored - logger.info "MailHandler: ignoring email from unknown user [#{email.from.first}]" if logger && logger.info + logger.info "MailHandler: ignoring email from unknown user [#{sender_email}]" if logger && logger.info return false end end |