I use Ruby on Rails, could you teach me how to use Mandrill to send and receive mail.
My problem is when the user enters text and clicks submit, I want the message to be sent to my mail. I read the documentation, but I do not understand this.
This is my development.rb, the same as production.rb
ActionMailer::Base.smtp_settings = {
:port => '587',
:address => 'smtp.mandrillapp.com',
:user_name => 'myemail@gmail.com',
:password => 's82SlRM5dPiKL8vjrJfj4w',
:domain => 'heroku.com',
:authentication => :plain
}
ActionMailer::Base.delivery_method = :smtp
user_mailer.rb:
class UserMailer < ActionMailer::Base
default from: "from@example.com"
def welcome
mail(to: "morumotto26@gmail.com", subject: "Welcome", body: "Have a nice day")
end
end
and in the controller:
def index
UserMailer.welcome.deliver
end
My log is as follows:
Started GET "/users/" for 127.0.0.1 at 2014-01-21 16:14:10 +0700
Processing by UsersController#index as HTML
Sent mail to morumotto26@gmail.com (2008.0ms)
Date: Tue, 21 Jan 2014 16:14:10 +0700
From: myemail@gmail.com
To: morumotto26@gmail.com
Message-ID: <52de3a62c89b2_5e8c9ea1881631@tnkjapan10.mail>
Subject: Welcome
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Have a nice day
Rendered text template (0.0ms)
Completed 200 OK in 2018ms (Views: 1.0ms | ActiveRecord: 0.0ms)
source
share