Created
March 11, 2015 14:34
-
-
Save yannski/ce11c812883969e455b2 to your computer and use it in GitHub Desktop.
Ruby Cold Mailing
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
require 'mail' | |
require 'csv' | |
require 'pry' | |
require 'active_support' | |
require 'active_support/core_ext/object/blank' | |
Mail.defaults do | |
delivery_method :smtp, address: ENV["SMTP_HOST"], port: ENV["SMTP_PORT"], user_name: ENV["SMTP_USER_NAME"], password: ENV["SMTP_PASSWORD"], authentication: :plain, enable_starttls_auto: true | |
end | |
def send_email recipient_email, firstname, is_buddy | |
text = <<-EOF | |
#{ is_buddy ? "Hello" : "Bonjour" } #{firstname}! | |
Scalingo a récemment été lauréat Orange Start-ups Day Strasbourg, une compétition de startups organisée par Orange. | |
C'est pourquoi j'aimerais #{ is_buddy ? "t'" : "vous " }inviter à fêter ça avec nous dans la grande boutique Orange, place Kléber à Strasbourg, mardi 17 mars de 10h à 18h. Ca sera l'occasion pour nous de #{ is_buddy ? "te" : "vous" } montrer la plate-forme Scalingo et ce qu'elle peut apporter. | |
Avec Scalingo nous essayons de répondre aux questions suivantes : | |
* Comment héberger facilement mes projets web ? | |
* Comment accélérer le cycle de vie de mes applications web ? | |
Voici une URL à partager dans #{ is_buddy ? "tes" : "vos" } réseaux : https://scalingo.com/orange-startups-day | |
RSVP : https://www.facebook.com/events/457483624407908/ | |
Yann Klis, | |
CEO at Scalingo | |
https://scalingo.com | |
https://twitter.com/ScalingoHQ | |
PS : si #{is_buddy ? "tu ne peux pas te" : "vous ne pouvez pas vous"} déplacer ce jour-là et qu'une démo #{ is_buddy ? "t'" : "vous " }intéresse, #{ is_buddy ? "fais" : "faites" }-moi signe. | |
EOF | |
mail = Mail.new do | |
from '[email protected]' | |
to recipient_email | |
subject "Invitation à une démo et une présentation de Scalingo" | |
body text | |
end | |
if ENV["DEBUG"] | |
puts mail.to_s | |
else | |
mail.deliver | |
puts "sent mail to #{recipient_email}" | |
end | |
end | |
CSV.foreach("invitations.csv", headers: true, return_headers: false) do |row| | |
if row["envoyeur"] == "YK" | |
if row["email"].present? | |
is_buddy = row["buddy"] == "yes" | |
send_email row["email"], row["prenom"], is_buddy | |
sleep 60*3 unless ENV["DEBUG"] # 5 minutes | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment