Reputation: 941
I'm new to Rails. How does sending mail in Rails 3 work?
It tried the following, but it doesn't work:
Calling the mailer:
@invited_user = InviteUser.where(:email => @user.email)
Mailer:
class InviteUsersMailer < ActionMailer::Base
default :from => "[email protected]"
def invite_biller_email(inviter_details)
@invitation_details = inviter_details
@user = User.find(@invitation_details.request_sent_by)
mail(:to => @invitation_details.email, :subject => "xxxxxxxxxxx")
end
end
Upvotes: 0
Views: 1744
Reputation: 12335
Easiest way - use gmail to save having to set up your own mail server. In an initializer file (eg. inside config/initializers/mailer.rb
), use the following code to adjust settings:
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:domain => 'yourwebdomain.com',
:user_name => '[email protected]',
:password => 'your password',
:enable_starttls_auto => true
}
After configuring, details on using the ActionMailer is found in the Ruby on Rails Guides.
After you have checked that it works, you can try setting up your own mail server (alternatively, you might have a webhost that runs a mail server for you, in which case re-configure above settings to do that).
Upvotes: 5
Reputation: 72534
Have a look at the Rails Guide for sending mails.
In a nutshell there are two things you have to do:
These steps and everything else is thoroughly covered in the Rails Guide.
Upvotes: 1