Getting Postfix sending email on your Mac

Fri Aug 21, 2009 by brett

I have recently been setting up my MacBook (running Leopard) to send email using the local email delivery system, i.e. Postfix. This means modifying the default installation to relay email through my ISP/email service - in my case; FastMail. I use FastMail because they have a nice secure email setup with both IMAP and SMTP access encrypted using SSL, but the instructions below will also work with Google Mail. The advantage of having your Apple Mac set up like this is that it enables command line scripts and various unix programs to send email. In my case, it allows me to use Mutt and Emacs as my email client.

The first step is to modify the main.cf file in the /etc/postfix directory. Use your favourite editor to do this, but you will need to sudo in order to modify the file. If you are using vi, type ‘sudo vi /etc/postfix/main.cf’ in a terminal window. Then search for a commented out “relayhost =” line and add the following:

relayhost = [mail.messagingengine.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = 
smtp_sasl_local_domain = yourdomain.com
#smtpd_sasl_application_name = smtpd
broken_sasl_auth_clients = yes
smtpd_pw_server_security_options = noanonymous
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom

Now I am relaying my email through the server mail.messagingengine.com and Postfix will attempt to connect to the server on port 587. The square brackets around “mail.messagingengine.com” tell Postfix not to do an MX lookup on the name, but just got to that IP address. You will want to modify these values to suit your ISP/email service. For GMail you can use the line:

relayhost=smtp.gmail.com:587

The next step is to create the file “/etc/postfix/sasl_passwd”. This file contains the information you need to use to authenticate yourself against the relaying mail server (in other words, your GMail username and password). Add the following lines to the /etc/postfix/sasl_passwd file:

[mail.messagingengine.com]:587 *username*:*password*

Or if you use GMail:

smtp.gmail.com:587 *username*@gmail.com:*password*

Remember to replace *username* with your actual username and *password* with your password.

From the Terminal command line, run the following commands:

sudo postmap hash:/etc/postfix/sasl_passwd
sudo chown root:wheel /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
sudo chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db

These commands create the “/etc/postfix/sasl_passwd.db” file from the “/etc/postfix/sasl_passwd” file, and then change the permissions on the file so that they can only be read by the root user.

Congratulations! You should now be good-to-go. Try sending an email from the command line by typing “mail -s ‘Test Email’ yourname@yourisp.com” at the command line. Type some words and then type “Ctrl-D” to finish. You can monitor the log file at /var/log/mail.log in order to see what is happening, and use the “mailq” program to see the state of the mail queue.

Blogging and SEO talk by Matt Cutts

Fri Aug 21, 2009 by brett

Matt Cutts gave an extremely interesting and dynamic talk at WordCamp about blogging and Search Engine Optimization. Not only was it extremely entertaining, but it contained lots of interesting tidbits about how to increase the PageRank of your site.

The Wire - 5 Seasons in 5 Minutes, sheee-it

Tue May 19, 2009 by brett

The Wire was an amazing series. Here is a summary:

Making your application viral

Mon May 18, 2009 by brett

Daniel Tenner has written an interesting post on how to make you application viral.

The core model for viral growth is the following: viral coefficient = (average number of users invited by each active user) x (proportion of invited users that actually join or become active) x (proportion of such users that invite others). Daniel provides a checklist of techniques designed to optimize the viral coefficient. The general techniques are as follows:

  • Make inviting people a core part of the process.
  • Keep pulling people back in
  • Be useful even if there are no other friends using the application.
  • Remove artificial invitation limits.

Detroit - Ground Zero for Economic Collapse

Mon May 11, 2009 by brett

Here is a video showing how badly Detroit has been affected by the collapsing housing market. Towards the end of the video you can see some amazing mansions in the worst-hit areas of Detroit that you can supposedly buy at a massive discount.

Social Collapse : Best Practices

Fri Feb 20, 2009 by brett

Hmmm…. first I read this transcript from a speech by Dmitry Orlov entitled “Social Collapse - Best Practices”, and then I saw on Boing Boing the post How are you coping with Collapse-Anxiety?

The first post describes what might happen if the US collapses in the same way economically as the USSR did in the 1990’s. It then goes on to making recommendations about what to focus on - essentially food, transportation, shelter and security. I thought it was fascinating because although I have been thinking for a number of years that the economic situation was going to get bad, I didn’t envision quite a collapse of that order of magnitude. As the crisis continues however, the possibility suddenly seems to become credible.

I found the comments interesting in the Boing Boing post. It seems as though quite a number of people were actually starting to find themselves in situations reminiscent of those described in the first post - primarily from posters in the US. Scary.

Comparison of Downturns

Fri Feb 20, 2009 by brett

A while ago, I created a Mathematica plot comparing the Great Depression, the Tech Crash and the Oil Crisis with the current financial crisis. This analysis was inspired by a chart I saw last year comparing these recessions with our current situation. Anyway, I thought it was worth bringing the chart up-to-date.

[Edit] The original chart I saw was this one.[/Edit]

Comparison of four economic downturns

Comparison of four economic downturns

Rehearsal for the Serenity's bar fight scene

Thu Feb 19, 2009 by brett

This is a rehearsal for the bar fight scene in the move “Serenity” (found via Reddit). I think this is actually better than the final scene in the movie.

Photos of London

Thu Jan 29, 2009 by brett

Here are some amazing photos of London from photographer Jason Hawkes. London is such a beautiful city and an amazing place to live!

Ghost-written by Who?

Tue Oct 21, 2008 by brett

Here is John Howard (Australia’s Prime Minister during the start of the last Iraq War), and Stephen Harper (Canada’s Prime Minister at the same time) giving the same, almost word-for-word speech in Parliament justifying the need to go to war.