Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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]) |> Seq.filter emailValidator
- System.IO.File.WriteAllLines(argv.[0] + "_out.txt", validEmails)
- let checkedEmails = validEmails |> Seq.map (fun e -> match CheckHost e with |Some res -> (e, res.Count) | None -> (e, 0))
- let badCount = checkedEmails |> Seq.filter (fun (e,c) -> c = 0) |> Seq.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