Postfix, Gmail and Mountain Lion Server
What a headache it’s been to get my mail server up and running — consistently — on Mac OS X 10.8! I guess the powers-that-be at Apple felt that it’d be a good idea to shift from /etc/postfix/ to /Library/Server/Mail/Config/postfix/ because… I don’t know, it has a proprietary ring to it perhaps? Who knows? Whatever the case it looks as though the transition was only partially complete, in that not all the paths were written and not all the directories were made.
If you’re like me and you’ve tried to strong arm control back over to /etc/postix then you’ve likely been just as frustrated that every time Apple updates the Server.app or serveradmin CLI (now burred deep within the Server.app, worth finding and adding to your $PATH) then all your s#!t breaks and you have to go back and do it again. Yeah for Apple Draconianism.
Since I can’t beat them, I might as well join them. So here are the steps to get Gmail piping out messages a la mail/sendmail/postfix from your command line with Mountain Lion 10.8, migrating from configurations in /etc/postfix/ to /Library/Server/Mail/Config/postfix/.
Assumptions
I assume a few things here:
- You have Server.app installed on your Mac.
- You’re comfortable in the command line.
- serveradmin have been buried recently. I suggest you add
/Applications/Server.app/Contents/ServerRoot/usr/sbinto your$PATH. - When I say “edit such-an-such file”, I assume that you have sudoer privileges and and an editor (VIM, Nano, TextMate, Sublime Text 2, etc…) that can edit these system files. In all of these examples I use
sublfor SublimeText, so substitute your favorite editor there. - Backup, backup, backup. Don’t edit any of these files without making a backup copy first.
- Since you’re here, let’s assume that you already know why you want to do this and how to use command-line mail.
How to
-
Stop the mail and postfix services:
$ sudo serveradmin stop mail $ sudo postfix stop
-
Let’s make sure you have the spool directory (one of those folders not originally created with the original release of the OS X 10.8 Server.app):
$ sudo mkdir -p /Library/Server/Mail/Data/spool
-
Open the postfix launch daemon:
$ sudo subl /System/Library/LaunchDaemons/org.postfix.master.plist
-
Replace the plist contents with:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>AbandonProcessGroup</key> <true/> <key>Label</key> <string>org.postfix.master</string> <key>OnDemand</key> <false/> <key>Program</key> <string>/usr/libexec/postfix/master</string> <key>ProgramArguments</key> <array> <string>master</string> </array> <key>QueueDirectories</key> <array> <string>/Library/Server/Mail/Data/spool/maildrop</string> </array> </dict> </plist> -
Unload/reload the plist:
$ sudo launchctl unload /System/Library/LaunchDaemons/org.postfix.master.plist $ sudo launchctl load /System/Library/LaunchDaemons/org.postfix.master.plist
-
Open the main.cf:
$ sudo subl /Library/Server/Mail/Config/postfix/main.cf
-
Find and replace all instances of
/etc/postfix/with/Library/Server/Mail/Config/postfix/ -
Add the following lines to the bottom:
# my main.cf edits relayhost = [smtp.gmail.com]:587 smtp_generic_maps = hash:/Library/Server/Mail/Config/postfix/generic smtp_tls_loglevel=1 smtp_tls_security_level=encrypt smtp_sasl_auth_enable=yes smtp_sasl_password_maps=hash:/Library/Server/Mail/Config/postfix/sasl/passwd smtp_sasl_security_options = noanonymous smtp_use_tls = yes
-
Find out who you are:
$ whoami
-
Open the aliases file:
$ sudo subl /Library/Server/Mail/Config/postfix/aliases
-
Find the line
#root: you, uncomment it and replace “you” with the results of whoami:# Person who should get root's mail. Don't receive mail as root! root: adam
-
Initialize the alias database:
$ sudo newaliases
-
Find out your machine name:
$ hostname
-
Open the generic file:
$ sudo subl /Library/Server/Mail/Config/postfix/generic
-
Add these lines to the end (with your credentials in place of whoami and hostname):
# my generic edits whoami@hostname [email protected] @hostname [email protected]
-
Create a password file:
$ sudo mkdir -p /Library/Server/Mail/Config/postfix/sasl $ sudo subl /Library/Server/Mail/Config/postfix/sasl/passwd
-
Add the following (with your credentials):
[smtp.gmail.com]:587 [email protected]:yourpassword
-
Set postfix permissions:
$ sudo postfix set-permissions $ sudo postmap /Library/Server/Mail/Config/postfix/sasl/passwd
-
Start the mail services:
$ sudo postfix start $ sudo serveradmin start mail
codepoet / CUPS-PDF for Mac OS X
CUPS-PDF is a backend module for CUPSMac OS Xs printing system by Volker C. Behr that, rather than printing to a device, prints straight to PDF files.
via codepoet / CUPS-PDF for Mac OS X / wiki / Home — Bitbucket.
Installing Pear on OS X 10.7 Lion
Nothing big, just need to document this stuff or else I forget…
$ sudo cp /private/etc/php.ini.default /private/etc/php.ini $ sudo php /usr/lib/php/install-pear-nozlib.phar $ sudo pear config-set php_ini /private/etc/php.ini $ sudo pecl config-set php_ini /private/etc/php.ini $ sudo pear upgrade-all
Lion Recovery Disk Assistant
“Built right into OS X Lion, Lion Recovery lets you repair disks or reinstall OS X Lion without the need for a physical disc.
The Lion Recovery Disk Assistant lets you create Lion Recovery on an external drive that has all of the same capabilities as the built-in Lion Recovery: reinstall Lion, repair the disk using Disk Utility, restore from a Time Machine backup, or browse the web with Safari.” — via Lion Recovery Disk Assistant.
LittleSnapper Touch Is Soon to Hit Realmac Lineup
[
](http://www.realmacsoftware.com/blog/index_files/littlesnapper_touch_iphone.php#unique-entry-id-35 “Realmac Software Blog – RapidWeaver News”)[This looks interesting](http://www.realmacsoftware.com/blog/index_files/littlesnapper_touch_iphone.php#unique-entry-id-35 “Realmac Software Blog – RapidWeaver News”), a companion iPhone application to [LittleSnapper](http://www.realmacsoftware.com/littlesnapper/ “LittleSnapper – Screen and Web Snapping for Mac OS X Leopard”) (desktop Mac app) and [QuickSnapper](http://www.quicksnapper.com/ “Welcome to QuickSnapper image hosting | QuickSnapper.com”) (web based snapshot sharing). It’s yet to be released but the new app, dubbed *LittleSnapper Touch* promises to allow the user to snap photos and webpages (or parts of them) and then post them to QuickSnapper.
Anyone familiar with QuickSnapper will be aware that you will, in turn, be able to pull down those snaps into the desktop version of LittleSnapper with a simple click of the “Send to LittleSnapper” button. It’s not clear yet whether there will be any syncing option that will negate this step. I guess we’ll have to wait and see.
Enabling Double Arrows in the Scroll Bar
Ohh, ohh, ohh, I can’t forget this one! This is one of those options you forgot you enabled with a utility like [Onyx](http://www.titanium.free.fr/pgs/english.html “Titanium Software”). So when you go and do your clean install of OS X and realize that some things are just not the same as they were, it’s the the little things like having double arrows at the top and bottom (or left and right) of a scroll bar that you miss.
Having vowed to take matters into my own hands with this install and being acutely aware of every system hack I make, I am documenting everything I do (on this blog) and I am making sure it’s something I can control via the terminal. So, instead of using Onyx, here is the terminal hack for enabling double arrows in your scroll bars:
defaults write "Apple Global Domain" AppleScrollBarVariant DoubleBoth
If you ever need to go back you just open the System Preferences (`/Applications/System Preferences.app`), click on appearance and choose one of the two defaults from “Place scroll arrows:”; “Together” or “At top and bottom”.
Control your processors in Mac OS X 10.5
Remarkably after nearly one month I am still trying to tweak my system just so. I think this is one of the last things though, my processor preference pane. By default, the CPU controls in Mac OS X 10.5 and not enabled and in fact, can’t be enabled unless you have the developer tools installed.
I like to be able to turn off some of my processors when I am just doing day to day web design and theme development. It’s a good way to save some energy (it’s good to be green) and to be totally honest, coding in HTML, CSS, PHP, Javascript and XML isn’t all that processor intensive. With the developer tool installed you can do this. There two things you can do, you can run the CPUPalette.app and/or you can install processor preference pane.
The CPUPalette.app can be found in `/Library/Application Support/HWPrefs/`. It’s a simple app that doesn’t allow much other than turning the processors on or off. If you click the little pill button in the top right-hand corner you can see a couple of basic preferences for window type, sampling rates and information display. It’s a quick and easy way to both monitor how your cores are being taxed and whether or not you can afford to shut a few of them down.
Your other option, if you you are already familiar with your processor usage, is to install the processor preference pane. Go to `/Developer/Extras/PreferencePanes` and find `Processor.prefPane`. Double click to install it. Once installed I highly suggest you click the “Show control in menu bar” for quick access. You’ll notice by installing the processor preference pane you get access to the CPUPalette.app without having to dig for it.
Auto mount/unmount your Mac volumes when required
Earlier this month you might recall the solution I gave you for [keeping unused volumes unmounted](http://www.seydoggy.com/2009/02/12/keeping-unused-hard-disks-unmounted/ “seyDoggy Web and Graphic Design – seyDoggy weblog – my thoughts on the web and the mac”) on your mac. The next part of the equation, automatically mounting those volumes when needed to run my backup scheme, took me a little longer to sort out. In fact I wasn’t able to write a solution on my own, try as I might, so I finally went searching for one.
I needed a script of some sort that would mount my unmounted volumes when it was time for [ChronoSync](http://www.econtechnologies.com/pages/cs/chrono_overview.html “ChronoSync | Perform File and Folder Synchronizations and Backups Like Clockwork | Econ Technologies”) to run and then unmount my volumes when ChronoSync was finished. After several IRC queries, forum posts here and there and countless Google searches I finally stumbled upon [this post](http://www.macosxhints.com/article.php?story=20060308154312630 “macosxhints.com – A script to mount/unmount a volume on app launch”) at Mac OS X Hints. This solution was the answer I needed and it works perfectly. I won’t recap the whole thing here, but I will give you the bits that were most important to me.
Copy the following script into *Script Editor.app* (`/Applications/AppleScript/Script Editor.app`), changing the `diskname` and `appname` to suite your needs:
property diskname : "MyDisk"
property appname : "ChronoSync"
on idle
tell application "System Events"
set x to the name of every process
if appname is not in x then
if (exists the disk diskname) then
do shell script "disktool -l | egrep -i "Mountpoint = '/Volumes/" & diskname & "" | cut -d\' -f2 | xargs -n1 disktool -p"
end if
else
do shell script "disktool -l | egrep -i "Mountpoint = '', fsType = 'hfs', volName = '" & diskname & "" | cut -d\' -f2 | xargs -n1 disktool -m"
end if
end tell
end idle
Next you need to save it as a bundled app and select “*Stay Open*”, give it a useful name and save it where you will be able to find it. In my case I chose `/Library/Scripts/ChronoSync/`:

Then you have to make it run in the background. To do this, find your newly created app, right click on it, “*Show Package Contents*”, find the Info.plist and open that in your favorite plain text editor. Above the key that says `CFBundleAllowMixedLocalizations` you want to add the following:
<key>LSBackgroundOnly</key>
<string>1</string>
Get out of the package and find your app again and double click on it. It should launch in the background but not show in the dock. You can see that it’s running by opening *Activity Monitor.app* (`/Applications/Utilities/Activity Monitor.app`):

Now to truly make this process automated, you need this app to be on when your computer is on, so it needs to launch when you login. So open your Accounts preference pane in System Preferences.app (`/Applications/System Preferences.app`), select the *Login Items* tab, select the  button and add your newly created app:

And that’s it! Next time your backup program fires up to do it’s regularly scheduled backups, your disk mounting app will mount your volume, wait for your backup app to finish and then quietly tuck your volume back up for the night.
##Other references
1. [A Script to mount/unmount a volume on app launch](http://www.macosxhints.com/article.php?story=20060308154312630 “macosxhints.com – A script to mount/unmount a volume on app launch”)
2. [An AppleScript to mount, run, unmount a disk image](http://www.macosxhints.com/article.php?story=20040905112951299 “macosxhints.com – An AppleScript to mount, run, unmount a disk image”)
3. [MountPart](http://www.well.com/~jfw/software/mountpart/ “John F. Whitehead – MountPart – Mount/Unmount Individual Partitions”)
I Give Apples New Safari 4 Beta a Spin
Apple announced today the launch of their [Safari 4 beta program](http://www.apple.com/safari/ “Apple – Safari – Introducing Safari 4 – See the web in a whole new way”) that claims to lead the way with innovation. I had to test this claim so I immediately downloaded it and gave it a spin. Here are my findings:
* On initial launch you are presented with the “Top Sites” window in which it appears that Safari scours your history for the most frequently visited sites in your recent cache and then throws up their thumbnails in a Core Animation like black gallery for you to pick from. Selecting the edit button allows you to remove items and make others sticky. I presume you can also add others that might actually be more indicative of your “Top Sites”. Again, in true Apple form, Apple seems to be hinging the success of a product on visual wow factor, but admittedly I could see myself making use of this.
* My next reaction was when I created a new tab and found that, a la Google Chrome, the tabs are on top. Why? While I will most certainly get used to it, what is the actual reason for this? I can’t find and difference in their functionality apart from the fact that you can only drag them about from their corner. Aside from that you can still drag them, move them from window to window, create a new window with each tab… there is one option I hadn’t noticed in previous version, “Add bookmark for these X tabs”. Is that new?
* Coverflow in Safari… there have been a few plugins to address this in the past. I guess they are history now. Do I need Cover Flow in Safari? I don’t need it iTunes or Finder so I probably won’t use it here either. But that said, it must be a popular enough technology if they keep throwing it in to their software.
* History search. Now *that* I like! I have always found searching the the history in the bookmarks folder to be painful and unproductive. This history search is insanely fast and (in Cover Flow form) even shows you screen shots of the sites that match your search terms.
* It claims to be faster, using the Nitro Engine. It could be but browsers and web technology today is getting so fast I would be hard pressed to notice the difference. It does seem to be faster overall but am I reacting to the guts of a finely tuned OS X Cocoa application or the page load? One note I will make about making browsers faster (and Safari 3 is already guilty of this), they cache things… unnaturally so which can make web development a nightmare. Safari 3 already caches it’s javascript and images in ways that cause web developers to have to reset their browsers all too often just to get an accurate response on their new projects. And faster also means pre-load, again which Safari 3 is bad for. Safari 3 will scour your main CSS file in search of things to load (like background images), whether or not that _thing_ is actually needed or even being used. I hope Safari 4 handles this a little better.
* The newish developer tools are nice (if your weren’t already playing with them in webkit), but I don’t know… it’s still not FireBug. You still can’t select code in the element window! How good is debuggin if I can’t edit what’s there or even copy and past it to a text editor? Seriously? As far as developer tools, these will give a glimpse into how your page is working, but they’re not much good for anything else.
* The full page zoom could be useful (hopefully not for a few years for me yet), but wow does it ever slow things down. Zoom in once and try page scrolling… not so fast now.
* I love, love, love the new address bar! If I am going to interface with browser in any way, it’s through the address bar so this improvement is quite welcome. Basically when you start typing in the address bar you are presented with much the same information your were before, but it’s clearly defined in two categories; history and bookmarks. In both cases it presents you with the site title followed by the URL which makes it very easy to get your bearings.
* The search field is now really slick too. It’s along the lines of Inquisitor, offering you suggestions and previous search queries. Very nice!
* CSS Animation, CSS Effects, CSS 3 Web Fonts… just more things to tease us web developers with. Stuff we won’t be able to use in the real world until all other browsers catch up. We can always dream though…
Overall, I think this is two things combined; a promising look at where web browsers should be and a sobering reminder of how much waiting for other browsers to get there will suck.
YourHead launches Stacks 1.0
Fellow RapidWeaver developer, Isaiah of [YourHead Software](http://www.yourhead.com/ “YourHead Software”) announced today that [Stacks](http://www.yourhead.com/stacks “Stacks”), a fluid layout plugin for [RapidWeaver](http://www.realmacsoftware.com/rapidweaver/ “RapidWeaver 4 – Powerful Web Design Software for Mac OS X”), is now official, hitting the big version 1.0. Those of you familiar with YourHead’s previous heavy hitting page layout tool, [Blocks](http://www.yourhead.com/blocks/ “Blocks”), will immediately recognize what this RapidWeaver plugin is all about, but the two are as different as night and day.
Don’t get me wrong, Blocks is a brilliant feat of plugin engineering and is the life blood of literally throngs of RapidWeaver users unable to do such layouts on their own. But it’s not a plugin that ever fit my web design sensibilities. The web is fluid, ever changing, growing, shrinking… for me, Blocks was too rigid.
Enter Stacks; a completely fluid, flexible, drag’n'drop all about layout tool for RapidWeaver that can generate oodles stacked up, blocked up, split up, embedded here and there kind of page layouts that only a pocket full of hand coded snippets could achieve perviously. Just like Blocks, Stacks allows to drop in text, HTML, images and whatnot, but then it allows to stacks onto stacks and those onto more stacks. You can make columns, columns in columns, columns where one column is an image, one is some code, one is some text, etc… drag that under some more columns… before you know it, you’ve got your very own [960 Grid System](http://960.gs/ “960 Grid System”) built into a RapidWeaver plugin.
If you are looking for the ultimate in flexible page layout with RapidWeaver, go [check out Stacks](http://www.yourhead.com/stacks/ “Stacks”). There are some great movies demonstrating the raw power of it and there is also and [Stacks API](http://www.yourhead.com/wikiwiki/index.php?title=Stacks_Library_API “Stacks Library API – YourHead”) if you’re interested in creating a custom Stacks library or two.

