auiktq
Last Updated: February 25, 2016
·
1.882K
· aaronjensen

Send email via AWS SES or Gmail from God

God doesn't expose tls functionality for its email by default. To enable it, add this to one of your god configs:

Net::SMTP.class_eval do
  def initialize_with_starttls(*args)
    initialize_without_starttls(*args)
    enable_starttls
  end

  alias_method :initialize_without_starttls, :initialize
  alias_method :initialize, :initialize_with_starttls
end

God::Contacts::Email.defaults do |d|
  d.from_email = "email@email.com"
  d.from_name = "From"
  d.server_host = "email-smtp.us-east-1.amazonaws.com"
  d.server_port = 587
  d.server_auth = :plain
  d.server_domain = "email.com"
  d.server_user = "user"
  d.server_password = "password"
end

If you want plain tls you can use enable_tls. If you want to use gmail, just replace the appropriate host. Hooray monkey patching!