Using Postfix to send out emails from development environment in Rails

Problem

You want to be able to send emails from your development enironment using Postfix in your (K)Ubuntu pc.

Solution

First you would need to install postfix:

and then you would need to change an option in postfix to not use tls, so change /etc/postfix/main.cf:

and change the smtpd_use_tls from yes to no:

restart your postfix server:

and then setup your config/development.rb as follows:

Testing Active_Mailer with GMail in 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 { ... }

cap deploy_with_migrations default behaviour

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:

in your config/deploy.rb