Last active
December 13, 2015 16:49
-
-
Save spickermann/4943543 to your computer and use it in GitHub Desktop.
rake task that generates a csv file containing invalid or unresolvable email addresses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc 'Generates a csv file containing invalid or unresolvable email addresses' | |
task :check_emails => :environment do | |
logger = Logger.new('log/faulty_emails.csv') | |
Account.find_each do |account| | |
identifier = "#{account.uuid},#{[account.current_sign_in_at, account.updated_at].compact.max},#{account.email}" | |
if !EmailUtils::Validator.valid?(account.email) | |
logger.warn("invalid,#{identifier}") | |
elsif !EmailUtils::Validator.resolvable_domain?(account.email) | |
logger.warn("dns_err,#{identifier}") | |
end | |
puts "processed accounts up to ##{account.id}" if account.id % 1_000 == 0 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment