Reputation: 7718
I'm trying to use Mail::Address
to parse an email address, however the output is not as expected:
Mail::Address.new('Arnold, Roa <[email protected]>').address
=> "Arnold"
What is the problem and what alternatives do I have?
Upvotes: 1
Views: 259
Reputation: 7718
I've created an issue on the github project: https://github.com/mikel/mail/issues/1219
In the meanwhile I created this monkey patch (which is not a good practice and should be avoided):
class Mail::Address
class << self
def new(value = nil)
if value.is_a? String
value = value.gsub(',', ' ')
end
super(value)
end
end
end
Upvotes: 0
Reputation: 11226
This works, not sure why the comma is there:
Mail::Address.new('Arnold, Roa <[email protected]>'.gsub(',','')).address
Upvotes: 1