Importing RSS Feeds into OSX Mail
I have about 150 feeds that I had previously been reading with Thunderbird. Since getting my hands on a MacBook Pro, I’ve switched to using Mail.app as my mail client (it’s nice!). The Problem is that Mail.app doesn’t provide an easy way of importing OPML (the format in which Thunderbird will export your RSS feeds).
Rather than skim through the exported OPML file & copy-paste each individual feed address into Mail.app, I (hastily) knocked together a php script - it doesn’t import directly into Mail.app, but rather puts your feed addresses into a simple text file that you can then copy-paste in one go (Mail.app -> File -> Add RSS Feeds ) .
#!/usr/bin/php
<?php
$file = "./MyThunderbirdFeeds.opml";
$doc = simplexml_load_file( $file );
$outfile = "./output.text";
$handle = fopen( $outfile, 'w' );
foreach( $doc->body->outline as $section )
{
foreach( $section->outline as $feed )
{
fwrite( $handle, $feed["xmlUrl"].”\\r\\n” );
}
}
fclose( $handle );
?>
Hopefully it might help someone out.
A few things to note:
- You need to give the script execute permissions before it’ll run (
chmod 755 ./extractScript.php
)
- You need to run the script in the same directory as the OPML export file
- The script expects an export file called ‘MyThunderbirdFeeds.opml’ (but you can change that by altering the value given to $file)
- Your feeds get dumped into a file called ‘output.text’ (again, change that if you want by putting a different file name into the $outfile variable)
