<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Joe Maller &#187; mail.app</title>
	<atom:link href="http://joemaller.com/tag/mailapp/feed/" rel="self" type="application/rss+xml" />
	<link>http://joemaller.com</link>
	<description>.com</description>
	<lastBuildDate>Fri, 27 Jan 2012 06:04:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Fixing Mail import crashes on Leopard</title>
		<link>http://joemaller.com/1075/fixing-mail-import-crashes-on-leopard/</link>
		<comments>http://joemaller.com/1075/fixing-mail-import-crashes-on-leopard/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 06:27:08 +0000</pubDate>
		<dc:creator>Joe Maller</dc:creator>
				<category><![CDATA[misc.]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mail.app]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://joemaller.com/?p=1075</guid>
		<description><![CDATA[After restoring from a Time Machine backup, Apple Mail would crash every time I tried to re-import my email archive. The problem seems to be affecting a lot of people who have mail that pre-dates OS X. The same crash also happens after migrating to a new machine. Quick fix Copy the following command and [...]]]></description>
			<content:encoded><![CDATA[<p>After restoring from a Time Machine backup, Apple Mail would crash every time I tried to re-import my email archive. The problem seems to be affecting a lot of people who have mail that pre-dates OS X. The same crash also happens after migrating to a new machine.</p>
<h3>Quick fix</h3>
<p>Copy the following  command and paste it into your Terminal. Press return and wait a few minutes. Once the command finishes, Mail should be able to import your messages.</p>
<pre><code>grep -lZr 'Content-disposition: attachment' ~/Library/Mail/Mailboxes/ | xargs -0 ruby -i -pe 'gsub(/(Content-type:[^;]*;\s*name=)"(.*)"/){$1+(if !$2.nil? then $2.dump.gsub(/\\\\/, "\\") end)}'</code></pre>
<h3>The problem</h3>
<p>The problem is specific to older, MacRoman encoded email messages with attachments whose filename includes non-ascii characters. For whatever reason, that freakshow edge-case combination will crash Apple Mail every time it tries to import those files. If by some stroke of luck you already have these messages in your email archive (I did), they can still crash Mail when trying to rebuild the containing mailbox. </p>
<p><img src="http://joemaller.com/wordpress/wp-content/uploads/2008/12/apple_mail_message_import.png" alt="" title="apple_mail_message_import" width="500" height="392" alt="Apple Mail Message Import dialog" /></p>
<p>The solution is sort of simple, just rename the attachment in the .emlx file. The harder part is finding which file to edit. </p>
<p>We&#8217;ll use grep to recursively search for a common token in these older files, then pass the filenames to a Ruby snippet which will filter the line containing the bad characters. Here is a section of a suspect message&#8217;s header: </p>
<blockquote><p><code>--B_3113094650_866203<br />
<strong style="font-weight:bold" >Content-type: application/octet-stream; name="SPWH 4.01ü.sit";</strong><br />
 x-mac-creator="53495421";<br />
 x-mac-type="53495435"<br />
<strong style="font-weight:bold" >Content-disposition: attachment</strong><br />
Content-transfer-encoding: base64</code></p></blockquote>
<p>The first bolded line contains the attachment name which is causing the problem, who knows what that umlaut was originally. The second bolded line is what we&#8217;re telling grep to locate, I couldn&#8217;t get anything to dependably match the oddball characters. &#8220;Content-disposition&#8221; appears to be an older attachment syntax and didn&#8217;t appear in any of my messages from after 2001.</p>
<p>While the Ruby script could be run from find&#8217;s exec command, it wouldn&#8217;t be particularly efficient. Calling the script from find would pass every .emlx file in the Mailboxes directory through Ruby&#8217;s gsub, which is almost wholly unnecessary (and much slower). Only 10 of my 57,007 messages needed fixing, 99.98% of them were fine.</p>
<h3>Is this safe?</h3>
<p>Since the most common way to encounter this bug involves Time Machine restores or migration to a new machine, most users should already be backed up. If something should go wrong, just restore the backup&#8217;s Library/Mail folder over the messed up one. You can also copy or zip the Library/Mail folder to another drive to be even safer.</p>
<p>That said, I ran dozens of iterations of this solution against copies of my personal Mail archive without issue. And besides, if you&#8217;re reading this, you might not have <em>any</em> of your old mail, so how much worse could it really get? </p>
<p>If you&#8217;re still worried, copy your ~/Library/Mail/Mailboxes folder to another drive, run the script, then compare directories with something like Apple&#8217;s <a href="http://en.wikipedia.org/wiki/Apple_Developer_Tools#FileMerge">FileMerge</a>. That will show you <em>exactly</em> which files have changed and what was changed inside them.</p>
<p>Renaming the attachment should be perfectly safe since the full encoded file contents are stored in the message. All the attachment name does is specify the filename, in a sense, it&#8217;s totally arbitrary. </p>
<p>I first submitted this bug with Apple back in May, if you have a developer account with Apple, please file a dupe for radar: 5912997</p>
]]></content:encoded>
			<wfw:commentRss>http://joemaller.com/1075/fixing-mail-import-crashes-on-leopard/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>iPhone vs. Apple Mail</title>
		<link>http://joemaller.com/784/iphone-vs-apple-mail/</link>
		<comments>http://joemaller.com/784/iphone-vs-apple-mail/#comments</comments>
		<pubDate>Fri, 06 Jul 2007 04:26:17 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mail.app]]></category>
		<category><![CDATA[pop]]></category>

		<guid isPermaLink="false">http://joemaller.com/2007/07/05/iphone-vs-apple-mail/</guid>
		<description><![CDATA[I&#8217;ve been seeing an issue with Apple Mail affecting several iPhone users on a several different of hosts: With a POP account, Apple&#8217;s Mail.app will ask for the password repeatedly, refuse the correct password and fail to collect any mail. With IMAP, the account seems to stall and does not necessarily update state or download [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been seeing an issue with Apple Mail affecting several iPhone users on a several different of hosts:</p>
<ul>
<li>With a POP account, Apple&#8217;s Mail.app will ask for the password repeatedly, refuse the correct password and fail to collect any mail.</li>
<li>With IMAP, the account seems to stall and does not necessarily update state or download new messages. Desktop IMAP behavior is particularly erratic.</li>
</ul>
<p>In both cases, the iPhone continues to work just fine. The problems mostly affects users who&#8217;ve set their iPhone to Auto-Check for mail to something other than Manual. The following lines appear in the Desktop&#8217;s console.log almost immediately after setting the iPhone to auto-check for mail:</p>
<pre><code>2007-07-05 15:33:17.190 Mail[21242] Unhandled response to command SELECT: * NO  Trying to get mailbox lock from process 28292
2007-07-05 15:34:24.098 Mail[21242] Unhandled response to command SELECT: * NO  Trying to get mailbox lock from process 29790
2007-07-05 15:36:14.917 Mail[21242] Unhandled response to command SELECT: * NO  Trying to get mailbox lock from process 31080</code></pre>
<p>Those entries seem to indicate that the IMAP server is sending a response that Apple Mail doesn&#8217;t know what to do with.</p>
<p>A <a href="http://forums.macrumors.com/showthread.php?t=323008">thread on the MacRumors forums</a> claimed this was a multiple connections issue with the mail server, but I think I&#8217;ve conclusively debunked that, at least for IMAP. </p>
<p>To test the multiple connection theory, I set up <a href="http://en.www.mozilla.com/en/thunderbird/">Thunderbird</a> on two other physical machines, one Mac and a Dell running Ubuntu, then set up my account using the default IMAP settings. I also opened my account in Horde webmail and hit reload a lot. Despite those simultaneous connections, Apple Mail seemed to be fine and messages were getting delivered. The little progress indicator was, however, still sitting there next to the account name, not spinning. </p>
<p>So now I can break Apple Mail just by turning on <em>Auto-Check</em> in iPhone&#8217;s <em>Settings->Mail</em>. Manual checking from the iPhone doesn&#8217;t cause any problems. So far I&#8217;m only seeing this on shared hosts running the Courier mail server.</p>
<p>IMAP is inconsistent about when it breaks, maybe relating related to server load issue.  POP will break every time: If I check my email on a POP account with the iPhone, Apple Mail will immediately ask for and then refuse the password for that account. </p>
<h3>An IMAP workaround</h3>
<p>Installing <a href="http://fivepoundsflax.blogspot.com/2007/06/imap-idle-news.html">IMAP-IDLE</a>, pretty much fixes the problems with IMAP. I&#8217;ve had this running for several hours and the iPhone checking every 15 minutes, and things seem to be working smoothly.  IMAP errors still appear in console.log but mail is getting through. I&#8217;m going to install this on a few other machines tomorrow and see what happens.</p>
<p>Not sure what to do about POP, but then we&#8217;re migrating everyone over to IMAP anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemaller.com/784/iphone-vs-apple-mail/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Deleting Unused mbox files</title>
		<link>http://joemaller.com/626/deleting-unused-mbox-files/</link>
		<comments>http://joemaller.com/626/deleting-unused-mbox-files/#comments</comments>
		<pubDate>Tue, 07 Mar 2006 21:44:29 +0000</pubDate>
		<dc:creator>Joe Maller</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[10.4]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mail.app]]></category>
		<category><![CDATA[mbox]]></category>

		<guid isPermaLink="false">http://joemaller.com/2006/03/07/deleting-unused-mbox-files/</guid>
		<description><![CDATA[Or, How I reclaimed 1.25 gigabytes of my hard drive. When 10.4 imported mail from the old 10.3 mbox files, it broke each message into an individual file so Spotlight could index them. The old mbox files, rightly, were left on the drive. For most people this wouldn&#8217;t take up a noticeable amount of space, [...]]]></description>
			<content:encoded><![CDATA[<p>Or, How I reclaimed 1.25 gigabytes of my hard drive.</p>
<p>When 10.4 imported mail from the old 10.3 mbox files, it broke each message into an individual file so Spotlight could index them. The old mbox files, rightly, were left on the drive. For most people this wouldn&#8217;t take up a noticeable amount of space, however those of us with a ton of mail saw a significant hit to our disk space. </p>
<p>The following commands will remove the unused mbox files from the drive, recovering a potentially large amount of disk space: </p>
<pre><code>    cd ~/Library/Mail
    find . -name "mbox" -ls</code></pre>
<p>Make sure the only thing listed are mbox files in your mail directory (they should be). To delete all those files, change the last &#8220;<code>-ls</code>&#8221; of the above command to &#8220;<code>-delete</code>&#8220;. (I didn&#8217;t include the full command on purpose since it deletes files and I wanted to strongly encourage everyone doing this to check the file list before deleting.) Just to be doubly safe, <a href='http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html'>backup</a> before doing this.</p>
<p>Total size of my mail folder went from 3.07 GB (3,206,511,328 bytes) to 1.84 GB (1,884,864,581). A savings of almost 1.25 GB. At <a href='http://eshop.macsales.com/item/Hitachi/0A25015/'>$229.00</a> for a 93.2 GB formatted notebook drive, that&#8217;s an actual cost savings of $3.02. </p>
<p>Note there was/is <a href='http://joemaller.com/2006/03/07/recovering-a-corrupted-email-mbox-with-104/'> a bug with Mail importing under 10.4</a> where very large mbox files don&#8217;t read correctly. Make sure all your messages really did import correctly before deleting your mbox files.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemaller.com/626/deleting-unused-mbox-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mbox files and Mail.app in 10.4</title>
		<link>http://joemaller.com/526/mbox-files-in-104/</link>
		<comments>http://joemaller.com/526/mbox-files-in-104/#comments</comments>
		<pubDate>Wed, 11 May 2005 17:30:18 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[emlx]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[mail.app]]></category>
		<category><![CDATA[mbox]]></category>

		<guid isPermaLink="false">http://joemaller.com/2005/05/11/post526/mbox-files-and-mailapp-in-104</guid>
		<description><![CDATA[One of the big under-the-hood changes to Mail.app in 10.4 is that messages are no longer in mbox files, this allows Spotlight to index individual messages without having to first parse out the contents of the entire mailbox. Despite being unused, the old mbox files are often still on the drive, which means that most [...]]]></description>
			<content:encoded><![CDATA[<p>One of the big under-the-hood changes to Mail.app in 10.4 is that messages are no longer in mbox files, this allows Spotlight to index individual messages without having to first parse out the  contents of the entire mailbox. Despite being unused, the old mbox files are often still on the drive, which means that most everyone’s mail is now taking up almost twice as much space as it did with 10.3. (my mail folder went from 1.4 to 2.8 gigs). If installing Tiger devoured a lot of hard drive space, that might account for a significant portion of where it went.</p>
<p>After an Archive &amp; Install upgrade, my ~/Library/Mail directory still has folders labeled <code>*.mbox</code>, but those folders each now contain a &#8220;Messages&#8221; directories which holds thousands of numbered *.emix files. Those mostly appear to be plain text files each containing one message. There is a small glob of XML plist data attached to the end of each file, as well an integer at the top of the file. The first integer is the message&#8217;s character/byte count from the end of the integer to the beginning of the XML data.</p>
<p>In theory, a fairly simple shell script could glom everything together into a standard mbox. Not sure how processor intensive that would be, but the steps to reassemble the data would be trivial. At very least Apple&#8217;s decision to move away from the mbox format can be easily reversed with no data loss.</p>
<p>Not much has been written about this, but I found this <a href="http://forums.macosxhints.com/showthread.php?s=&amp;threadid=39164">MacOS X Hints mbox thread</a> which confirms what I&#8217;m seeing:</p>
<blockquote><p>
I used to be able to use mutt or pine to view the mbox mailboxes in <strong>~/Library/Mail/&lt;account&gt;/&lt;box&gt;/mbox</strong> . In 10.4 these are still present, but appear not to be updated any more. The up to date emails are in <strong>~/Library/Mail/&lt;account&gt;/&lt;box&gt;/Messages/*.emlx</strong> which I believe is required for spotlight to be able to index messages &#8211; it only indexes file-based entities, not subportions of files.</p></blockquote>
<p>Because <a href='http://www.bombich.com/software/ccc.html'>Carbon Copy Cloner</a> doesn’t work with 10.4 yet, I can’t comfortably back up my drive and experiment with deleting the old mboxes. It seems like it should be safe to remove all mbox files and associated files, nothing outside the Messages directories has been modified since I upgraded to 10.4. If anyone has more information, please leave a comment.</p>
<p>(While reading a little background on the mbox format, I found the original RFC for email as a text file. The W3c also has an <a href='http://www.w3.org/Protocols/rfc822/'>HTML version of RFC822</a>, partially converted by (sir) <a href='http://www.w3.org/People/Berners-Lee/'>Tim Berners-Lee</a>. It’s fun to encounter raw history like that.)</p>
<p><strong>Update</strong> I posted <a href="http://joemaller.com/2006/03/07/deleting-unused-mbox-files/">a simple command to delete unused Mbox files</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://joemaller.com/526/mbox-files-in-104/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching 1/24 queries in 0.023 seconds using disk: basic
Object Caching 392/445 objects using disk: basic

Served from: joemaller.com @ 2012-02-08 12:50:56 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          tag/mailapp/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.804s
Header info:
Set-Cookie:         bb2_screener_=1328723456+38.107.179.220+38.107.179.220; path=/
X-Pingback:         http://joemaller.com/wordpress/xmlrpc.php
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Wed, 08 Feb 2012 17:50:56 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Wed, 08 Feb 2012 18:50:56 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               3269d00f6cdd9db7285a482ee0aa6a9c
X-Powered-By:       W3 Total Cache/0.9.2.4
Content-Encoding:   gzip
-->
