Skip to content

Instantly share code, notes, and snippets.

@adis-io
Created April 19, 2016 15:04
Show Gist options
  • Save adis-io/97d0edad6e246e0ae7ab6741c21beacd to your computer and use it in GitHub Desktop.
Save adis-io/97d0edad6e246e0ae7ab6741c21beacd to your computer and use it in GitHub Desktop.
Ruby script to send email though ActionMailer
require 'action_mailer'
ActionMailer::Base.smtp_settings = {
address: 'smtp.yourserver.com', # default: localhost
port: '25', # default: 25
user_name: 'user',
password: 'pass',
authentication: :plain # :plain, :login or :cram_md5
}
class Test < ActionMailer::Base
default from: 'sender@test.test'
def test
mail(to: 'atapys@gmail.com',
subject: "Test") do |format|
format.html { render :text => 'Test body' }
format.text { render :text => 'Test body' }
end
end
end
message = Test.test # => Returns a Mail::Message object
message.deliver_now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment