How to get domain from email

后端 未结 3 374
-上瘾入骨i
-上瘾入骨i 2021-02-02 07:15

How do I get the domain from an email-adress in ruby?

3条回答
  •  失恋的感觉
    2021-02-02 07:59

        >>  email = "Sahil Grover"        
        => "Sahil Grover"
    
        >> mail = Mail::Address.new(email)         
        => #| >
    
        >> mail.instance_values        
        => {"output_type"=>:decode,
           "parsed"=>true,
         "data"=>#,
         "display_name"=>"Sahil Grover"}
    
        >> mail.domain        
        => "stackoverflow.com"
    

提交回复
热议问题