speaking incoming mail

Brian Medley bpm-list-osx-unix at 4321.tv
Fri Mar 12 09:43:06 PST 2004


Hi,

For a while I've wanted to have some notification for when work
email arrives.  I recently got it to work via procmail, perl, and
applescript.  Below is what I used:

procmail.rc:

:0:                                                                                                           
* ^From.*bobm at work\.com
{                                                                                                             
    :0hc                                                                                                      
    | (/sw/bin/formail -c -x "From:") | $HOME/bin/speakaddress.pl                                             
                                                                                                              
    :0:                                                                                                       
    inbox                                                                                                     
}                                                                                                             

speakaddress.pl:

#! /usr/bin/perl                                                                                              
                                                                                                              
use strict;                                                                                                   
use warnings;                                                                                                 

# these two modules need to be installed via cpan or wherever you
# get your modules
use Mac::AppleScript qw(RunAppleScript);                                                                      
use Mail::Address;                                                                                            
                                                                                                              
MAIN:                                                                                                         
{                                                                                                             
    my $address = <>;                                                                                         
                                                                                                              
    my ($addr) = Mail::Address->parse($address);                                                              
                                                                                                              
    my $speech = $addr->name() ? $addr->name() : $addr->user();                                               
                                                                                                              
    # Bob McDougal has a habit of not putting his full name on
    # his emails.
    if ("bobm" eq $speech) {                                                                              
        $speech = "Bob McDougal";                                                                          
    }                                                                                                         
                                                                                                              
    my $script = qq(                                                                                          
        tell application "Finder" to say "Mail from $speech"                                                  
    );                                                                                                        
    &RunAppleScript($script);                                                                                 
                                                                                                              
    exit 0;                                                                                                   
}                                                                                                             

-- 
~`^`'~=-._.-=~'`^`'~=-._.-=~'^'~=-., \|/  (___)  \|/ _,.-=~'`^`
                                      @~./'O o`\.~@
      "Knowledge is Power"           /__( \___/ )__\  *PPPFFBT!*
         -- Francis Bacon               `\__`U_/'
 _.-=~'``'~=-._.-=~'``'~=-._.-=~'`^`'~= <____|'  ^^`'~=-.,__,.-=
~'^`'~=-._.-=~'`^`'~=-._.-=~'^'~=-.,__,.-==--^'~=-.,__,.-=~'`^`



More information about the X-Unix mailing list