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