Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (26 sloc) 915 Bytes
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
SendgridCloudfoundryRails::Application.initialize!
# get Sendgrid credentials from ENV variable
credentials = host = username = password = ''
if !ENV['VCAP_SERVICES'].blank?
JSON.parse(ENV['VCAP_SERVICES']).each do |k,v|
if !k.scan("sendgrid").blank?
credentials = v.first.select {|k1,v1| k1 == "credentials"}["credentials"]
host = credentials["hostname"]
username = credentials["username"]
password = credentials["password"]
end
end
end
# overwrite ActionMailer settings to send through SendGrid servers
ActionMailer::Base.smtp_settings = {
:address => host,
:port => '587',
:authentication => :plain,
:user_name => username,
:password => password,
:domain => 'example.com',
:enable_starttls_auto => true
}