View Source:
MuttOnMacOs
Note:
This page has been locked and cannot be edited.
!!Mutt On Mac Os X __Note 5/21/11__: these instructions are obviously quite old. Lots of stuff in here is still relevant, but there have been some changes. For example, I think the mutt that comes in macports now supplies everything you need. mutt-ng is abandoned. -phil ----- My current home system is an Apple Powerbook 667DVI running Mac OS X 10.4.3. I've been using mutt as my mail editor on that platform and it works quite well. Here are some things I've learned: You need to first install [fink|http://fink.sourceforge.net], the collection of free gnu/linux/etc software for Mac OS X. The following fink packages are generally useful in conjunction with mutt: * aspell * spell checker * lynx * text-mode web browser (useful for previewing html documents) * openssl & openssl-devel * necessarily if you want ssl support in mutt * gdbm & gdbm-shlibs * necessary if you want header caching in mutt Fink does include mutt but the version is somewhat old. I elected to build [mutt-ng|http://mutt-ng.berlios.de] from source and use it instead. Mutt-ng is a more experimental split from mutt that incorporates a number of extra patches. I hacked mutt-ng two ways before running the configure: 1. Change the tempfile name string so that other programs think it is old mutt: <pre> --- muttlib.c.orig 2005-12-13 00:41:12.000000000 -0500 +++ muttlib.c 2005-12-13 13:50:03.000000000 -0500 @@ -657,10 +657,8 @@ void _mutt_mktemp (char *s, const char *src, int line) { - - snprintf (s, _POSIX_PATH_MAX, "%s/muttng-%s-%d-%d-%d-%x%x", NONULL (Tempdir), - NONULL (Hostname), (int) getuid (), (int) getpid (), Counter++, - (unsigned int) rand(), (unsigned int) rand()); + snprintf (s, _POSIX_PATH_MAX, "%s/mutt-%s-%d-%d", NONULL (Tempdir), + NONULL (Hostname), (int) getpid (), Counter++); debug_print (1, ("%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s)); unlink (s); } </pre> 2. Make configure look in <code>/sw</code> for gdbm: <pre> --- configure.orig 2005-12-13 13:52:57.000000000 -0500 +++ configure 2005-12-13 00:43:36.000000000 -0500 @@ -14528,7 +14528,7 @@ fi; if test x$ac_prefer_gdbm != xno -a x$ac_cv_vlopen != xyes; then ac_cv_gdbmopen=no - GDBM_DIRS="$mutt_cv_prefix /usr/local /usr" + GDBM_DIRS="$mutt_cv_prefix /usr/local /usr /sw" echo "$as_me:$LINENO: checking for gdbm_open" >&5 echo $ECHO_N "checking for gdbm_open... $ECHO_C" >&6 for d in $GDBM_DIRS; do </pre> Then I ran configure as follows: <pre> ./configure --enable-hcache --enable-imap --with-ssl </pre> and did the usual <code>make && make-install</code> to install in /usr/local. I chose not to install in /sw to keep Fink packages (which go in /sw by default) separate from packages I built myself. Next I needed an editor to use with mutt. Previously I used vim on Mac OS X. but I decided I really wanted emacs back. The answer is [Aquamacs Emacs|http://aquamacs.org]. Aquamacs is by far the best emacs for Mac OS: * Its a native Mac OS program so you don't have to launch X11 to run it. * It incorporates both the emacs keybindings and the mac keybindings in a logical way. I have a heavily customized .emacs file so starting Aquamacs fresh for each mail message is not practical. I also use the post.el mode in emacs to edit my messages. The answer is emacsclient, which attaches to a running emacs and displays a fresh edit window. Aquamcs comes with it's own emacsclient, you can't just use the <code>/usr/bin/emacsclient</code> installed by default (that is for the lame stock emacs that comes with Mac OS). Move that one aside and link in the Aquamacs version: <pre> $ sudo mv /usr/bin/emacsclient /usr/bin/emacsclient.orig $ sudo ln -s /Applications/Aquamacs\ Emacs.app/Contents/MacOS/bin/emacsclient /usr/bin/ </pre> Then I made sure I had the [latest post.el|http://sourceforge.net/projects/post-mode/] and set up my .emacs as indicated in that file. Normally now I would just change my mutt editor to emacsclient in <code>~~/.muttngrc</code>. However, I discovered a slight annoyance: when you call emacsclient from mutt in the Mac terminal, the new window appears *behind* the terminal window. The fix (as suggested on the [Emacs on Mac mailing list|http://article.gmane.org/gmane.emacs.macintosh.osx/1735]) was a script like this: <pre> #!/bin/sh # script to force Aquamacs to open in front of terminal open -a Aquamacs\ Emacs /Applications/Aquamacs\ Emacs.app/Contents/MacOS/bin/emacsclient "$@" # Now make sure the focus goes back to the terminal when we are done open -a Terminal </pre> which ensures the editor window opens in front of the terminal and also makes sure the terminal gets the focus after the editor window closes. I saved this script as <code>~~/bin/emacs-mail</code> and set my mutt editor to point to the script. Works like a charm. One slight weakness is that if your mouse pointer is over a different terminal window when the editor window closes, that other terminal will get the focus instead of the terminal running mutt. Haven't thought of a fix for that yet. Another improvement I still need to make is instead of just blindly running emacsclient to edit a message, I need to do two things: # Check if emacs is already running and launch it if not. # Check if you are running in a graphical environment and launch a text-mode editor if not. Number 2 isn't terribly important on the mac unless you ssh in to the system. Otherwise you can pretty much always assume you've got a GUI. Note there are a few issues with post.el that need to be worked out: First, the 'check if message contained the string attach and ask user for attachment' functionality is broken. If this is triggered in a message, you get an error message when attempting to close the window with C-cC-c. It looks like the problem in post.el is here: <pre> ;; "13 occurences" instead of a number, 13. (let ((total-attach (string-to-int (how-many post-attachment-regexp)))) ;; And this mess is just to catch the unlikely false alarm of ;; "attach" being in the signature, but not in the body. (if (> total-attach 0) (progn (post-goto-signature) (> total-attach (string-to-int (how-many post-attachment-regexp))))))) </pre> Specifically the call the <code>string-to-int</code> seems to actually get a number instead of a string so it bombs out. The fix is this patch to post.el: <pre> --- post.el.orig 2005-12-15 23:04:03.000000000 -0500 +++ post.el 2005-12-15 23:09:49.000000000 -0500 @@ -1083,15 +1083,14 @@ "Check if attach appears in the body." (post-goto-body) - ;; Aargh it's annoying that how-many returns a string, - ;; "13 occurences" instead of a number, 13. - (let ((total-attach (string-to-int (how-many post-attachment-regexp)))) + ;; how-many apparently used to return a string but now it + ;; returns an int so we don't need string-to-int. + (let ((total-attach (how-many post-attachment-regexp))) ;; And this mess is just to catch the unlikely false alarm of ;; "attach" being in the signature, but not in the body. (if (> total-attach 0) (progn (post-goto-signature) - (> total-attach (string-to-int (how-many - post-attachment-regexp))))))) + (> total-attach (how-many post-attachment-regexp)))))) (defun post-prompt-for-attachment () "Prompt for an attachment." </pre> Or you can disable the check for attachments in post.el: <pre> (post-should-prompt-for-attachment (quote Never)) </pre> Second, the default underline display in Aquamacs is broken just as it is in XEmacs and all other Emacsen I've ever seen: the underline gets drawn through the characters instead of under them. Supposedly this is due to some font weirdness in X11, etc. Anyway, I changed the underline to a nice sunken box instead with this .emacs change: <pre> (post-underline-face ((((class color) (background dark)) (:box (:line-width 1 :color "grey75" :style released-button))))) </pre> Note that the default underline in Aquamacs in general has the same problem so I also added this: <pre> (underline ((t (:box (:line-width 1 :color "grey75" :style released-button))))) </pre> Third, emacs uses the tempfile name to determine whether to turn on post mode. This gets confused by two things: # Even the latest post.el can't quite understand mutt-ng tempfile names. Regular mutt just uses the system name plus the pid plus a counter to construct the name. Mutt-ng adds several other numbers, presumably to make tempfile handling more secure. The lazy fix for this is the patch to muttlib.c above. The better fix would be to work with the post.el maintainer and fix the regex. # If you are on a cable mode or dsl, you might have a system name like <code>abc-100-43-56-33.comcast.net</code>, i.e. your system name contains your ip address. The extra numbers break the post.el regex. I fixed number two by forcing my system name to something sensible. I changed three items: # Under system preferences->sharing, you can set the system name. Unfortunately this doesn't change the results of the <code>hostname</code> call and that is what mutt users. # I created an <code>/etc/rc.local</code> and added one line: <code>/bin/hostname sysname</code>. This changes the hostname on boot. However I think it still might break when running on dhcp. # Finally I also edited /etc/hostconfig and added the line <code>HOSTNAME=sysname</code>. That was suggested on the net, but its not clear if this mechanism still works in Mac OS 10.4. Anyway after all that now my system name is always the same, and it doesn't confuse post.el. !Sending Mail Mutt doesn't come with any mail transfer agent functionality. That is, it doesn't know how to actually _send_ mail. Mutt assumes some other program on the system will take care of that little detail. This makes sense in the unix world because unix machines typically have an MTA like sendmail installed. There are several options: # Use the Postfix mailer that comes with Mac OS. * Seems like overkill if you just want to send mail from one program. # Use muttng and link to the libesmtp library, which will give mutt the ability to send mail itself. * I couldn't get libesmtp or esmtp to build under Mac OS 10.4. # Use a standalone outgoing MTA like esmtp, msmtp, or nullmailer I had used libesmtp under Mac OS 10.3.9 but I couldn't get it built under 10.4. Thus I went looking for an alternative and found [msmtp|http://msmtp.sourceforge.net]. Seems to offer similar features to esmtp, including various authentication and encryption options. This is important as I want to use mutt for my work mail and I have to authenticate with that server. I built msmtp 1.4.4 with the standard <code>configure & make & make install</code>. Then I updated my .muttngrc to call it: <pre> set sendmail="/usr/local/bin/msmtp" </pre> I also needed to configure my <code>~~/.mstmp</code> with my mail server, username, and password. After that mutt was sending mail with no problems. ----- CategoryGeekStuff CategoryMacStuff
Please enable JavaScript to view the
comments powered by Disqus.
HollenbackDotNet
Home Page
Popular Pages
All Categories
Main Categories
General Interest
Geek Stuff
DevOps
Linux Stuff
Pictures
Search
Toolbox
RecentChanges
RecentNewPages
What links here
Printable version
AllPages
RecentChanges
Recent Changes Cached
No changes found
Favorite Categories
ActionPage
(150)
WikiPlugin
(149)
GeekStuff
(137)
PhpWikiAdministration
(102)
Help/PageList
(75)
Help/MagicPhpWikiURLs
(75)
Blog
(69)
Pictures
(60)
GeneralInterest
(44)
LinuxStuff
(38)
Views
View Page
View Source
History
Diff
Sign In