Entries tagged with “development”.


Problem
You want to test your email configuration and be able to send emails in your development environment, using a GMail account in a Rails application using 2.3.2.

Solution
Start your console in your development environment:

./script/console

Add the following replacing your GMail details:


ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "your_gmail_domain",
:authentication => :plain,
:user_name => "your_gmail_user_name",
:password => "your_gmail_password"}

Add a simple email class:


class MyMailer < ActionMailer::Base
def test_email
@recipients = "an_address_to_sent_to@domain.com"
@from = "address_from@your_google_domain.com"
@subject = "test from dev console"
@body = "this is the body"
end
end

and to finally test the email:


MyMailer::deliver_test_email

if it doesn't return with an error but with something like:


TMail::Mail port=#TMail::StringPort:id=0x..fdab4cee0 bodyport=#TMail::StringPort:id=0x..fdab4a9ec

then it should be working so add the configuration to your environments/development.rb

config.action_mailer.smtp_settings { ... }

Problem
When using cap deploy_with_migrations, the default behaviour is to deploy with the migrations in the production environment.

Solution
To change this behavior add:

set  :rails_env,  "development"

in your config/deploy.rb