Created
April 19, 2016 15:04
-
-
Save adis-io/97d0edad6e246e0ae7ab6741c21beacd to your computer and use it in GitHub Desktop.
Ruby script to send email though ActionMailer
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
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