Script for manually sending emails
require 'mail' | |
require 'csv' | |
FILE = ARGV[0] | |
Mail.defaults do | |
delivery_method :smtp, { | |
address: 'smtp address', | |
port: 587, | |
domain: 'gmail.com', | |
user_name: 'craig.kerstiens@gmail.com', | |
password: ENV.fetch('EMAIL_PASSWORD'), | |
authentication: :plain, | |
enable_starttls_auto: true | |
} | |
end | |
def send_email(address, app) | |
mail = Mail.new do | |
to address | |
from 'Craig Kerstiens <craig.kerstiens@gmail.com>' | |
subject "Your email subject in here" | |
body generate_body(app) | |
end | |
end | |
def generate_body(app) | |
%Q( | |
Hi, | |
Your list of apps: | |
#{app} | |
Various email content in here... | |
) | |
end | |
CSV.parse(File.read(FILE)).each do |line| | |
address = line[0] | |
app = line[1] | |
m = send_email(address, app) | |
puts m.to_s | |
p m.deliver! | |
puts | |
puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment