diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 519d9e04d..2fdb84366 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -2,26 +2,10 @@ class ApplicationMailer < ActionMailer::Base append_view_path Rails.root.join('app', 'views', 'mailers') layout 'mailer' - before_action :verification_before_send - def registrant_confirm_url(domain:, method:) token = domain.registrant_verification_token base_url = ENV['registrant_portal_verifications_base_url'] "#{base_url}/confirmation/#{domain.name_puny}/#{method}/#{token}" end - - def verification_before_send - p '===================================================================' - p '===================================================================' - p '===================================================================' - p '===================================================================' - p '===================================================================' - p mail - p '===================================================================' - p '===================================================================' - p '===================================================================' - p '===================================================================' - p '===================================================================' - end end diff --git a/lib/tasks/collect_invalid_validation_contacts.rake b/lib/tasks/collect_invalid_validation_contacts.rake new file mode 100644 index 000000000..aa681c495 --- /dev/null +++ b/lib/tasks/collect_invalid_validation_contacts.rake @@ -0,0 +1,38 @@ +namespace :collect_invalid_contacts do + desc 'Starts collect invalid validation contacts' + task all_domains: :environment do + Contact.all.each do |contact| + result = Truemail.validate(contact.email, with: :mx) + unless result.result.success + collect_data_for_csv(contact, result.result) + end + end + end +end + +def find_related_domains(contact) + Domain.where(id: contact.id) +end + +def collect_data_for_csv(contact, result) + domains = find_related_domains(contact) + + headers = %w[ + contact + domain + error + ] + + CSV.open('invalid_email.csv', 'w') do |csv| + csv << headers + + domains.each do |domain| + attrs = [] + attrs.push(domain) + attrs.push(contact.email) + attrs.push(result.errors) + + csv << attrs + end + end +end \ No newline at end of file