Skip to content

Instantly share code, notes, and snippets.

@nachoal nachoal/sender.rb
Created Feb 27, 2019

Embed
What would you like to do?
require 'mail'
require 'csv'
password = 'AQUI TU CONTRASEÑA'
user = "AQUI TU CORREO (gmail)"
csv_options = { col_sep: ',', quote_char: '"', headers: :first_row }
filepath = 'correos.csv'
options = {
address: 'smtp.gmail.com',
port: 587,
user_name: user,
password: password,
authentication: 'plain',
enable_starttls_auto: true
}
Mail.defaults do
delivery_method :smtp, options
end
CSV.foreach(filepath, csv_options) do |row|
Mail.deliver do
to row['Correos']
from user
subject 'Gracias por probar nuestro servicio!'
body "Muchas gracias por suscribirte a nuestro servicio #{row['nombre']}, estamos buscando a tu bringer"
end
puts "Correo enviado a #{row['Correos']}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.