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:

sudo apt-get install postfix

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

sudo vi /etc/postfix/main.cf

and change the smtpd_use_tls from yes to no:

smtpd_use_tls=no

restart your postfix server:

sudo /usr/sbin/postfix reload

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

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:                 "127.0.0.1",
  port:                    25,
  enable_starttls_auto:    false
}

Command line mail message with postfix in (K)ubuntu

Problem

You have installed postfix in your local development machine (sudo apt-get install postfix), and you want to test sending emails from the command line using mail email_address@someone.com

 

Solution

You would first need to install the mailutils package:

sudo apt-get install mailutils

then you can send an email by:

mail email_name@example.com
CC: (leave blank)
Subject: Test subject
Main message body

and you can send it by pressing Ctrl+D

Redirecting postfix email to a different email account

Problem

You have setup your Rails app to send out emails using postfix, but you also want to redirect the incoming emais to a different account.

Solution

Edit the postfix configuration file vi /etc/postfix/main.cf and add the following two lines at the bottom:

virtual_alias_domains = outgoing_domain.com
virtual_alias_maps = hash:/etc/postfix/virtual

And then add the redirections to the virtual file with vi /etc/postfix/virtual:

outgoing_email@outgoing_domain.com           other_account@other_domain.com
@outgoing_domain.com                         other_account@other_domain.com

Then run the following two commands to restart postfix:

postmap /etc/postfix/virtual
postfix reload

* Based on the post here

Creating a Vagrant Box with Debian Lenny 32, rvm and Ruby 1.9.3

As an addition to the excellent beta book ‘Deploying Rails’, as I had problems using the suggested lucid64 image, I’ve tried to install a debian lenny 32 image with rvm and Ruby 1.9.3.

The steps needed are listed below

 

  1. Download the lenny package:
    localhost$ vagrant box add debian-lenny-32 https://s3-eu-west-1.amazonaws.com/glassesdirect-boxen/debian/debian_lenny_32.box
  2. Make a new directory for the virtual box:
    localhost$ mkdir -p ~/deployingrails/lenny32
  3. change into created directory and create the Vagrant file:
    localhost$ cd ~/deployingrails/lenny32
    vagrant init
  4. change the Vagrant file to use the virtual box we have downloaded:
    Vagrant::Config.run do |config|
      config.vm.box = "lenny32"
    end
  5. Start the VM:
    localhost$ vagrant up
  6. If there is a warning about the Guest additions here install the latest guest additions by following the description here, but only use the update and upgrade steps as:
    localhost$ vagrant ssh
    vagrant$ sudo apt-get update
    vagrant$ sudo apt-get upgrade
  7. After finishing the upgrade logout (exit) from the VM and issue the command to restart the VM:
    localhost$ vagrant reload
  8. login to the VM again:
    localhost$ vagrant ssh
  9. Install curl to be able to download the installation script for:
    vagrant$ sudo apt-get install curl
  10. Download and install rvm by using the script described here http://beginrescueend.com/rvm/install/ :
    vagrant$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
  11. Add the loading of the RVM function into .bashrc, by running the following in the command prompt:
    vagrant$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
  12. Reload the bashrc file:
    vagrant$ source ~/.bashrc
  13. Make sure that the rvm is loaded as function:
    vagrant$ type rvm | head -1
    rvm is a function
  14. Run the rvm requirement to see the needed libraries and then run the suggested ones (except libreadline6 and libreadline6-dev that are not there in debian):
    vagrant$ sudo apt-get install build-essential openssl curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
  15. Install Ruby 1.9.3 :
    vagrant$ rvm install ruby-1.9.3
  16. Use the ruby 1.9.3 as default:
    vagrant$ rvm use 1.9.3 --default
  17. Finally create a new VM package to use in future:
    localhost$ vagrant package --output lenny32-rvm-ruby193
  18. And add it our box list:

    localhost$ vagrant box add lenny32-rvm-ruby193 lenny32-rvm-ruby193
    localhost$ vagrant box list

Could not open library ‘libgtkmm-2.4.so’: libgtkmm-2.4.so: cannot open shared object file: No such file or directory.

Problem

If you have setup guard with your Rails project and you are trying to run it in an (K)Ubuntu installation you get the following message:

Could not open library 'libgtkmm-2.4.so': libgtkmm-2.4.so: cannot open shared object file: No such file or directory.

Solution

Install the missing library with the following:

sudo apt-get install libgtkmm-2.4

multiple user installation of rvm in Debian

Problem
You would like to install rvm as a multiple user installation in Debian.

Solution
You would need to do the following:

as root

  • bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

for each individual user you want to use rvm

  • in the user’s .bashrc or .bashrc_profile add the following at the bottom:
    [[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm" # This loads RVM into a shell session.
  • reload the .bashrc or .bashrc_profile by:
    source .bashrc|.bashrc_profile

and you should be able to do rvm -v.

Error while loading shared libraries – Mandriva

Problem
After installing a package and trying to run it in Mandriva 2010 64, you get errors about missing libraries, like:

error while loading shared libraries: libasound.so.2: cannot open shared object file: No such file or directory

Solution
Use the urpmf command to find the packages that contain the missing libraries like :

urpmf libasound.so.2

and then when you get something like the following:

lib64alsa2:/usr/lib64/libasound.so.2
lib64alsa2:/usr/lib64/libasound.so.2.0.0
lib64alsa2:/usr/lib64/libasound.so.2
lib64alsa2:/usr/lib64/libasound.so.2.0.0
libalsa2:/usr/lib/libasound.so.2
libalsa2:/usr/lib/libasound.so.2.0.0
libalsa2:/usr/lib/libasound.so.2
libalsa2:/usr/lib/libasound.so.2.0.0

install the missing packages with:

sudo urpmi lib64alsa2
or/and
sudo urpmi libalsa2