Commit e1037ef7 authored by maeda's avatar maeda

Parse author's name enclosed in parentheses in the From field when creating a...

Parse author's name enclosed in parentheses in the From field when creating a user account from an email (#17699).

Patch by Go MAEDA.


git-svn-id: https://svn.redmine.org/redmine/trunk@17914 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 62c6daa0
......@@ -544,12 +544,9 @@ class MailHandler < ActionMailer::Base
# Creates a User for the +email+ sender
# Returns the user or nil if it could not be created
def create_user_from_email
from = email.header['from'].to_s
addr, name = from, nil
if m = from.match(/^"?(.+?)"?\s+<(.+@.+)>$/)
addr, name = m[2], m[1]
end
if addr.present?
if from_addr = email.header['from'].try(:addrs).to_a.first
addr = from_addr.address
name = from_addr.display_name || from_addr.comments.to_a.first
user = self.class.new_user_from_attributes(addr, name)
if handler_options[:no_notification]
user.mail_notification = 'none'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment