Advertisement
Guest User

Untitled

a guest
Apr 10th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.12 KB | None | 0 0
  1. // Learn more about F# at http://fsharp.net
  2. // See the 'F# Tutorial' project for more help.
  3.  
  4. let CheckHost email =
  5.     let addr = new System.Net.Mail.MailAddress(email)
  6.     let res = ActiveUp.Net.Mail.Validator.GetMxRecords(addr.Host)
  7.     if res <> null then Some(res) else None
  8.  
  9. [<EntryPoint>]
  10. let main argv =
  11.     let emailValidator = (new System.ComponentModel.DataAnnotations.EmailAddressAttribute()).IsValid
  12.     let validEmails = System.IO.File.ReadAllLines(argv.[0]) |> Array.filter emailValidator
  13.     System.IO.File.WriteAllLines(argv.[0] + "_out.txt", validEmails)
  14.     let checkedEmails = validEmails |> Array.Parallel.choose (fun e-> let res = CheckHost e
  15.                                                                       match res with | Some c -> Some((e,c.Count)) | None -> None)
  16.     let badCount = validEmails.Length - checkedEmails.Length
  17.     printfn "%d bad emails" badCount    
  18.     System.IO.File.WriteAllLines(argv.[0] + "_out2.txt", validEmails)
  19.     printfn "%f bad emails" (float(badCount) / float(Seq.length checkedEmails))
  20.     System.Console.ReadLine() |> ignore
  21.     0 // return an integer exit codes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement