Skip to content

Instantly share code, notes, and snippets.

@nachoal
Created February 27, 2019 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nachoal/e25553ecfb584d59065b51a27b27c743 to your computer and use it in GitHub Desktop.
Save nachoal/e25553ecfb584d59065b51a27b27c743 to your computer and use it in GitHub Desktop.
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