<?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>André Aulich &#187; Mail</title>
	<atom:link href="http://www.andre-aulich.de/en/perm/category/mail/feed" rel="self" type="application/rss+xml" />
	<link>http://www.andre-aulich.de/en</link>
	<description>Digital Asset Management &#38; Workflow Automation</description>
	<lastBuildDate>Mon, 16 Jan 2012 12:42:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>iPad Printing – Send PDF as email to Mac OS X Server 10.6</title>
		<link>http://www.andre-aulich.de/en/perm/ipad-printing-%e2%80%93-send-pdf-as-email-to-mac-os-x-server-10-6</link>
		<comments>http://www.andre-aulich.de/en/perm/ipad-printing-%e2%80%93-send-pdf-as-email-to-mac-os-x-server-10-6#comments</comments>
		<pubDate>Wed, 12 May 2010 11:43:06 +0000</pubDate>
		<dc:creator>André Aulich</dc:creator>
				<category><![CDATA[Mac OS X Server]]></category>
		<category><![CDATA[Mail]]></category>

		<guid isPermaLink="false">http://www.andre-aulich.de/en/?p=303</guid>
		<description><![CDATA[Well, everybody seems to be asking why the iPad can&#8217;t print files, yet. If you are looking for iPad printing solutions, you might have come across funny approaches like this one, but this article is about a serious solution. Credits: &#8230; <a href="http://www.andre-aulich.de/en/perm/ipad-printing-%e2%80%93-send-pdf-as-email-to-mac-os-x-server-10-6">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, everybody seems to be asking why the iPad can&#8217;t print files, yet.</p>
<p>If you are looking for iPad printing solutions, you might have come across funny approaches <a href="http://www.engadget.com/2010/04/15/ipad-printing-solved/">like this one</a>, but this article is about a serious solution.</p>
<p><strong>Credits: to use Mac OS X Server&#8217;s mail services to provide printing features for the iPad was Armin Briegel&#8217;s idea. You can follow him on <a href="http://twitter.com/titanonearth">Twitter</a>. I was just the guy to write the few lines of code.</strong></p>
<p>The idea is very easy: iPad&#8217;s iWork applications as well as other iPad apps can export PDF files, which you can send to an email address of choice.</p>
<p>If now you use a Mac OS X Server machine (can be a Mac mini server, e.g.) which runs mail services to print all PDF files sent to a specific address, you have an easy solution to the iPad printing &#8220;challenge&#8221;.</p>
<p>I guess you know how to set up Mac OS X Server 10.6 to run basic mail services, if not, read <a href="http://www.oreilly.de/catalog/macosxsrvrkommplger/">my wonderful O&#8217;Reilly book</a> on it <img src='http://www.andre-aulich.de/en/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' />  The book comes in german only, so see it as a chance to improve your german <img src='http://www.andre-aulich.de/en/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' />  , or get in touch with O&#8217;Reilly, that you want it translated into english.</p>
<p>So this is how it works:</p>
<h2>1. List available printers and test them</h2>
<p>First open the Terminal on your Mac OS X Server 10.6 and type the following line to see which printers are available for our mail printer.<br />
<code>mothership:iPadPrint root# lpstat -a<br />
EPSON_Perfection_2480_2580 accepting requests since Mon Aug 31 18:33:07 2009<br />
Fax accepting requests since Tue May 11 21:25:40 2010<br />
hp_deskjet_5550 accepting requests since Tue May 11 21:55:46 2010</code><br />
In this example you see that there are three printers available on my machine, where the EPSON device actually is a scanner, and there is a Fax available, too, but imagine that there are multiple printers you might want to use.</p>
<p>Now try if you can print PDF files to one of your printers:<br />
<code>lp -d "hp_deskjet_5550" 1.pdf</code><br />
In the line above replace &#8220;hp_deskjet_5550&#8243; with the name of your printer. Replace &#8220;1.pdf&#8221; with the absolute file path of a pdf file.<br />
If this works fine, go to the next step.</p>
<h2>2. Set up printing mail accounts on Mac OS X Server</h2>
<p>I assume that your Mac OS X Server runs as an Open Directory Master. Now open the Workgroup Manager and create a new mail account for your printer. In my case the user will be called &#8220;hp_deskjet_5550&#8243;, the domain is &#8220;andre-aulich.de&#8221;, so the complete email address will be &#8220;hp_deskjet_5550@andre-aulich.de&#8221;.</p>
<p><strong>Note:</strong> If you don&#8217;t want some Internet folks printing thousands of pages on your machines, make sure that this machine can not be reached from the internet. If this is not possible, create a dedicated internal domain which can not be reached from outside.</p>
<p>This is how the new account looks like in Workgroup Manager:<br />
<img src="http://www.andre-aulich.de/en/wp-content/uploads/2010/05/wgmanagerprinter_1.jpg" alt="" title="wgmanagerprinter_1" width="589" height="531" class="aligncenter size-full wp-image-313" /><br />
<img src="http://www.andre-aulich.de/en/wp-content/uploads/2010/05/wgmanagerprinter_2.jpg" alt="" title="wgmanagerprinter_2" width="589" height="531" class="aligncenter size-full wp-image-314" /><br />
Save theses settings, send an email without any attachements, and a second one with a PDF file as attachment to this account, and then open the Terminal and change into your dovecot&#8217;s mail directory:<br />
<code>mothership:mail root# cd /var/spool/imap/dovecot/mail<br />
mothership:mail root# ls -al<br />
total 0<br />
drwxrwxr-x  10 _dovecot         mail   340 Mar 25 09:56 .<br />
drwxr-xr-x   4 root             wheel  136 Aug 31  2009 ..<br />
drwx------  15 valerie          mail   510 Nov 10  2009 14167B4C-211D-4AA9-A2B4-4641AD5C508B<br />
drwx------  25 andre            mail   850 May 12 11:38 22D9FA73-A1CA-4981-AD37-3E06D7E4F457<br />
drwx------  13 public           mail   442 Nov 10  2009 2AF362D6-E665-48D7-98AF-E347B055135A<br />
drwx------  11 ab               mail   374 Mar 12 10:48 2EF9F9D2-69FD-4670-B1FE-2C8FC55D3675<br />
drwx------  16 ical             mail   544 Jan 15 16:32 A1BB97FC-5E6D-491C-AAED-F8B9212FE3D3<br />
drwx------  10 hp_deskjet_5550  mail   340 Mar 25 09:56 B806EEC7-9C41-49B7-8D7C-DF507DFE21DF<br />
drwx------  16 sadmin           mail   544 Nov 18 12:15 E8043686-DCCC-432F-BD96-85C400288357<br />
drwxrwxrwx   7 andre            mail   238 Nov 10  2009 Public<br />
mothership:mail root# cd B806EEC7-9C41-49B7-8D7C-DF507DFE21DF/<br />
mothership:B806EEC7-9C41-49B7-8D7C-DF507DFE21DF root# ls -al<br />
total 32<br />
drwx------  10 hp_deskjet_5550  mail  340 Mar 25 09:56 .<br />
drwxrwxr-x  10 _dovecot         mail  340 Mar 25 09:56 ..<br />
drwx------   2 hp_deskjet_5550  mail   68 Mar 25 09:56 cur<br />
-rw-------   1 hp_deskjet_5550  mail   84 Mar 25 09:56 dovecot-uidlist<br />
-rw-------   1 hp_deskjet_5550  mail    8 Mar 25 09:56 dovecot-uidvalidity<br />
-rw-------   1 hp_deskjet_5550  mail    0 Mar 25 09:56 dovecot-uidvalidity.4bab2555<br />
-rw-------   1 hp_deskjet_5550  mail  220 Mar 25 09:56 dovecot.index.log<br />
-rw-------   1 hp_deskjet_5550  mail   11 Mar 25 09:56 maildirsize<br />
drwx------   3 hp_deskjet_5550  mail  102 Mar 25 09:56 new<br />
drwx------   2 hp_deskjet_5550  mail   68 Mar 25 09:56 tmp<br />
mothership:B806EEC7-9C41-49B7-8D7C-DF507DFE21DF root# cd new<br />
mothership:cur root# ls -al<br />
total 0<br />
drwx------   2 hp_deskjet_5550  mail   68 Mar 25 09:56 .<br />
drwx------  10 hp_deskjet_5550  mail  340 Mar 25 09:56 ..<br />
-rw-------   1 hp_deskjet_5550  mail   1.3K May 12 12:02 1273658576.M795669P68535.mothership.intern,S=1327,W=1364:2,<br />
-rw-------   1 hp_deskjet_5550  mail   1.3K May 12 12:03 1273658602.M6558P68554.mothership.intern,S=1325,W=1362:2,<br />
-rw-------   1 hp_deskjet_5550  mail    77K May 12 12:05 1273658717.M385494P68662.mothership.intern,S=78367,W=79416:2,<br />
-rw-------   1 hp_deskjet_5550  mail    77K May 12 12:05 1273658742.M267533P68676.mothership.intern,S=78365,W=79414:2,</code><br />
What have we done here? Dovecot stores emails in /var/spool/imap/dovecot/mail. We list the content of the folder and see that each user has its own folder, named like the UUID of the user. If you don&#8217;t know how to look up the UUID of a user, or if you just don&#8217;t want to spend the time doing it, just look for the folder which is owned by our new printer user.<br />
If you need to look up the UUID of our newly created user, you can also type<br />
<code>dscl /LDAPv3/127.0.0.1 -read /Users/hp_deskjet_5550 | grep apple-generateduid</code><br />
in Terminal to get an output like this:<br />
<code>dsAttrTypeNative:apple-generateduid: C784550D-B2A6-4881-8DAF-0FC96D4BE8ED</code><br />
Now you can search for the mail folder of our freshly created mail user.<br />
In the code above we see that the folder B806EEC7-9C41-49B7-8D7C-DF507DFE21DF is owned by hp_deskjet_5550, so we change into this directory and list its contents. New mails will always be copied into the &#8220;new&#8221; folder, so we change into this directory and list its content, which already holds 4 emails in my case.</p>
<h2>3. Extract attachments from emails and print them</h2>
<p>First, make sure you have <a href="http://www.macports.org/">MacPort</a>s installed, then install ripmime:<br />
<code>bash-3.2# port install ripmime<br />
--->  Computing dependencies for ripmime<br />
--->  Fetching ripmime<br />
--->  Attempting to fetch ripmime-1.4.0.6.tar.gz from http://lil.fr.distfiles.macports.org/ripmime<br />
--->  Verifying checksum(s) for ripmime<br />
--->  Extracting ripmime<br />
--->  Configuring ripmime<br />
--->  Building ripmime<br />
--->  Staging ripmime into destroot<br />
--->  Installing ripmime @1.4.0.6_0<br />
--->  Activating ripmime @1.4.0.6_0<br />
--->  Cleaning ripmime</code></p>
<p>Now, create a new directory and a bash script which we are going to use for further automation:<br />
<code>mkdir -p /usr/local/iPadPrint/<br />
cd /usr/local/iPadPrint/<br />
touch printpdfs<br />
chmod +x printpdfs</code><br />
Open the script using nano and insert the following code:<br />
<code>#!/bin/bash<br />
TMPDIR="/usr/local/iPadPrint/tmp/"<br />
mkdir -p /usr/local/iPadPrint/tmp/<br />
for i in /var/spool/imap/dovecot/mail/C784550D-B2A6-4881-8DAF-0FC96D4BE8ED/new/*; do<br />
        if [[ "$(grep "Content-Type: application/pdf;" "$i")" == "" ]]; then<br />
                echo "Deleting file $i as it holds no pdf files."<br />
                rm "$i"<br />
        else<br />
                echo "Printing pdf attachment(s) of file $i"<br />
                /opt/local/bin/ripmime -i "$i" -d "$TMPDIR"<br />
                rm "$i"<br />
        fi<br />
done<br />
for i in "$TMPDIR"*; do<br />
        if [[ "$i" != *.pdf ]]; then<br />
                echo "$i deleted. No pdf file"<br />
                rm -r "$i"<br />
        else<br />
                echo "$i will be printed."<br />
                lp -d "hp_deskjet_5550" "$i"<br />
                rm "$i"<br />
        fi<br />
done</code></p>
<p>You can also download the script from <a href='http://www.andre-aulich.de/en/wp-content/uploads/2010/05/printpdfs1.zip'>here</a>. Just extract it, copy it into /usr/local/iPadPrint and make it executable.<br />
Change /var/spool/imap/dovecot/mail/C784550D-B2A6-4881-8DAF-0FC96D4BE8ED/new/* to match your environment.<br />
Now invoke the script.</p>
<p>It will extract all attachments out of your emails. If an email doesn&#8217;t contain a pdf file, it will be deleted without printing.<br />
The tool will print all contained pdf files and delete everything after printing.</p>
<h2>4. Automate it</h2>
<p>To run this whenever a new email arrives in the account of our printer mail account, download <a href='http://www.andre-aulich.de/en/wp-content/uploads/2010/05/de.andre-aulich.ipadprinter.plist_.zip'>this file</a>, copy it into /Library/LaunchDaeomons, and make sure, its permissions look like this:<br />
<code>-rw-r--r--   1 root  wheel   458 May 12 13:38 de.andre-aulich.ipadprinter.plist</code><br />
Change the line <string>/var/spool/imap/dovecot/mail/C784550D-B2A6-4881-8DAF-0FC96D4BE8ED/new/</string> to match your environment.<br />
Then load the job:<br />
<code>launchctl load -w /Library/LaunchDaemons/de.andre-aulich.ipadprinter.plist</code></p>
<p>Now Mac OS X Server 10.6 automatically discovers new print jobs you send via email and prints all included pdf files to the selected printer.</p>
<p>You can use this solution to work with multiple printers by simply creating more scripts and launchd jobs.</p>
<p>Hope this helps!</p>
<p>P.S.: Most cli commands need to be invoked as root user or with sudo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andre-aulich.de/en/perm/ipad-printing-%e2%80%93-send-pdf-as-email-to-mac-os-x-server-10-6/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Presentation in Berlin: Mac OS X Server 10.6 as communication platform for Mac, Windows, Linux, and iPhone</title>
		<link>http://www.andre-aulich.de/en/perm/presentation-in-berlin-mac-os-x-server-10-6-as-communication-platform-for-mac-windows-linux-and-iphone</link>
		<comments>http://www.andre-aulich.de/en/perm/presentation-in-berlin-mac-os-x-server-10-6-as-communication-platform-for-mac-windows-linux-and-iphone#comments</comments>
		<pubDate>Thu, 25 Feb 2010 12:11:17 +0000</pubDate>
		<dc:creator>André Aulich</dc:creator>
				<category><![CDATA[Calendars]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Mac OS X Server]]></category>
		<category><![CDATA[Mail]]></category>

		<guid isPermaLink="false">http://www.andre-aulich.de/en/?p=250</guid>
		<description><![CDATA[On Tuesday, March 2nd 2010, I am going to present Mac OS X Server 10.6 as the central communication platform for Mac OS X, Windows, Linux, and iPhone. I will follow the setup guide described in my new book published &#8230; <a href="http://www.andre-aulich.de/en/perm/presentation-in-berlin-mac-os-x-server-10-6-as-communication-platform-for-mac-windows-linux-and-iphone">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On Tuesday, March 2nd 2010, I am going to present Mac OS X Server 10.6 as the central communication platform for Mac OS X, Windows, Linux, and iPhone.</p>
<p>I will follow the setup guide described in my new book published by O&#8217;Reilly (in german). Everything will be done using a live demo system.</p>
<p>More information regarding entry fee, location, etc. can be found at <a href="http://www.lob.de/pics/BK04_Veranstaltung02032010.jpg">http://www.lob.de/pics/BK04_Veranstaltung02032010.jpg</a>.</p>
<p>I am looking forward to seeing you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andre-aulich.de/en/perm/presentation-in-berlin-mac-os-x-server-10-6-as-communication-platform-for-mac-windows-linux-and-iphone/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My new Mac OS X Server 10.6 book has just been published by O&#8217;Reilly</title>
		<link>http://www.andre-aulich.de/en/perm/my-new-mac-os-x-server-10-6-book-has-just-been-published-by-oreilly</link>
		<comments>http://www.andre-aulich.de/en/perm/my-new-mac-os-x-server-10-6-book-has-just-been-published-by-oreilly#comments</comments>
		<pubDate>Thu, 25 Feb 2010 11:51:54 +0000</pubDate>
		<dc:creator>André Aulich</dc:creator>
				<category><![CDATA[Calendars]]></category>
		<category><![CDATA[Mac OS X Server]]></category>
		<category><![CDATA[Mail]]></category>

		<guid isPermaLink="false">http://www.andre-aulich.de/en/?p=248</guid>
		<description><![CDATA[My new Mac OS X Server 10.6 book has just been published by O&#8217;Reilly. It&#8217;s available in german and explains you how to set up your own mail, calendar, addressbook, and webserver based on Mac OS X Server 10.6 within &#8230; <a href="http://www.andre-aulich.de/en/perm/my-new-mac-os-x-server-10-6-book-has-just-been-published-by-oreilly">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My new Mac OS X Server 10.6 book has just been published by O&#8217;Reilly.</p>
<p><img src="http://www.andre-aulich.de/wp-content/uploads/2010/02/macosxsrvrkommplger.s.gif" alt="" title="macosxsrvrkommplger.s" width="153" height="198" class="aligncenter size-full wp-image-300" /></p>
<p>It&#8217;s available in german and explains you how to set up your own mail, calendar, addressbook, and webserver based on Mac OS X Server 10.6 within no time.</p>
<p>You find more details about it at <a href="http://www.oreilly.de/catalog/macosxsrvrkommplger/">O&#8217;Reilly</a>. The focus of the book is to use Mac OS X Server as the communication central for your Mac OS X, Windows, Linux, and iPhone users.</p>
<p>I&#8217;d appreciate your feedback!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andre-aulich.de/en/perm/my-new-mac-os-x-server-10-6-book-has-just-been-published-by-oreilly/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac OS X Server 10.6: accept mails with empty subject line</title>
		<link>http://www.andre-aulich.de/en/perm/mac-os-x-server-10-6-accept-mails-with-empty-subject-line</link>
		<comments>http://www.andre-aulich.de/en/perm/mac-os-x-server-10-6-accept-mails-with-empty-subject-line#comments</comments>
		<pubDate>Sun, 11 Oct 2009 09:10:58 +0000</pubDate>
		<dc:creator>André Aulich</dc:creator>
				<category><![CDATA[Mac OS X Server]]></category>
		<category><![CDATA[Mail]]></category>

		<guid isPermaLink="false">http://www.andre-aulich.de/en/?p=211</guid>
		<description><![CDATA[If you use Mac OS X Server 10.6 (Snow Leopard Server) as a mail server, by default it rejects mails without a subject line. If you want to change this behavior, you just need to open the file /etc/postfix/main.cf and &#8230; <a href="http://www.andre-aulich.de/en/perm/mac-os-x-server-10-6-accept-mails-with-empty-subject-line">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you use Mac OS X Server 10.6 (Snow Leopard Server) as a mail server, by default it rejects mails without a subject line.</p>
<p>If you want to change this behavior, you just need to open the file /etc/postfix/main.cf and change the line</p>
<p><code>header_checks = pcre:/etc/postfix/custom_header_checks</code></p>
<p>to</p>
<p><code># header_checks = pcre:/etc/postfix/custom_header_checks</code></p>
<p>Afterwards, type</p>
<p><code>sudo postfix reload</code></p>
<p>to activate the new setting.</p>
<p>You could also change the rule set in /etc/postfix/custom_header_checks to do the same thing, yet, as currently the only rule in this file is to reject incoming mails with an empty subject, we can easily ignore the whole file like described above.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andre-aulich.de/en/perm/mac-os-x-server-10-6-accept-mails-with-empty-subject-line/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

