Last active
December 1, 2015 17:16
-
-
Save paxti/4f19eb3b9e1dc9d3e0e5 to your computer and use it in GitHub Desktop.
This file contains 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
def send_emails | |
mg_client = Mailgun::Client.new ENV["MAILGUN_API_KEY"] | |
mb_obj = Mailgun::BatchMessage.new(mg_client, ENV["MAILGUN_DOMAIN"]) | |
mb_obj.set_from_address(ENV["MAILGUN_EMAIL"], | |
{"first"=>"Firs tname", | |
"last" => "Last name" | |
} | |
); | |
mb_obj.set_subject("New message!"); | |
mb_obj.set_text_body("Hello %recipient.first%, | |
This is the text body of the message | |
using recipient variables! | |
If you needed to reference the account-id | |
recipient variable, you could do it like | |
this: %recipient.account_id%."); | |
find_users.each do |recipient| | |
mb_obj.add_recipient(:to, recipient[:email], recipient); | |
end | |
message_ids = mb_obj.finalize | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment