Results 1 to 4 of 4

Thread: Conky mail script

  1. #1
    Join Date
    Apr 2008
    Beans
    382

    Conky mail script

    I would like to show new mail count for my Yahoo, Gmail and Hotmail. Can anyone point me to the right direction. Thanks

  2. #2
    Join Date
    Aug 2007
    Location
    Atlanta, GA
    Beans
    179
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: Conky mail script

    http://ubuntuforums.org/showthread.p...ght=conky+mail

    add to conky:
    Code:
    ${texeci 600 /home/YOUR_NAME/scripts/email.pl}
    Create the email.pl file:
    Code:
    #!/usr/bin/perl
    
    # beginning of configuration
    
    # pop3 host
    $pop_host = "pop_server";
    
    # pop3 username 
    $pop_user = "usr_name";
    
    # pop3 password
    $pop_pass = "password";
    
    # ssl port number
    $ssl_port = "995";
    
    # ssl protocol
    $ssl_prot = "tcp";
    
    # number of emails to show
    $dis_numb = "5";
    
    # end of configuration
    
    use Mail::POP3Client;
    use IO::Socket::SSL;
    
      my $socket = IO::Socket::SSL->new( PeerAddr => $pop_host,
                                         PeerPort => $ssl_port,
                                         Proto    => $ssl_prot);
      my $pop = Mail::POP3Client->new();
      $pop->User($pop_user);
      $pop->Pass($pop_pass);
      $pop->Socket($socket);
      $pop->Connect();
    
    $msg_count = $pop->Count();
    
    for ($i = $msg_count, $j = 0; $i >= $msg_count-($dis_numb-1); $i--, $j++) {
      foreach ( $pop->Head( $i ) ) {
        #/^(From|Subject):\s+/i and print $_, "\n";
        if ($_ =~ m/^From:/) {
          ($from) = ($_ =~ m#^From: .*<(.*)>#);
          $from = substr($from, 0, 30);
          $out .= "$j = $from\n";
        }
      }
      #chop $out;
      `echo -e "$out"> ~/.gmail/.gmail_top`;
    }
    
    $pop->Close();
    For gmail, I think the pop server is pop.gmail.com... put in your username and password


    I'm just snipping that from the OP... You may want to read the thread for more info.

  3. #3
    Join Date
    Sep 2009
    Beans
    26

    Re: Conky mail script

    hey this script sounds promising but only works until line 25, because i get this error.

    Code:
    Conky: desktop window (1e00d6b) is subwindow of root window (13c)
    Conky: window type - override
    Conky: drawing to created window (0x5800001)
    Conky: drawing to double buffer
    Can't locate Mail/POP3Client.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /home/gargintua/scripts/email.pl line 25.
    BEGIN failed--compilation aborted at /home/gargintua/scripts/email.pl line 25.
    Can't locate Mail/POP3Client.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /home/gargintua/scripts/email.pl line 25.
    BEGIN failed--compilation aborted at /home/gargintua/scripts/email.pl line 25.
    my script looks like this excluding account info.

    Code:
    #!/usr/bin/perl
    
    # beginning of configuration
    
    # pop3 host
    $pop_host = "pop3.live.com";
    
    # pop3 username 
    $pop_user = "user";
    
    # pop3 password
    $pop_pass = "pass";
    
    # ssl port number
    $ssl_port = "995";
    
    # ssl protocol
    $ssl_prot = "tcp";
    
    # number of emails to show
    $dis_numb = "5";
    
    # end of configuration def. POP3Client
    
    use Mail::POP3Client;
    use IO::Socket::SSL;
    
      my $socket = IO::Socket::SSL->new( PeerAddr => $pop_host,
                                         PeerPort => $ssl_port,
                                         Proto    => $ssl_prot);
      my $pop = Mail::POP3Client->new();
      $pop->User($pop_user);
      $pop->Pass($pop_pass);
      $pop->Socket($socket);
      $pop->Connect();
    
    $msg_count = $pop->Count();
    
    for ($i = $msg_count, $j = 0; $i >= $msg_count-($dis_numb-1); $i--, $j++) {
      foreach ( $pop->Head( $i ) ) {
        #/^(From|Subject):\s+/i and print $_, "\n";
        if ($_ =~ m/^From:/) {
          ($from) = ($_ =~ m#^From: .*<(.*)>#);
          $from = substr($from, 0, 30);
          $out .= "$j = $from\n";
        }
      }
      #chop $out;
      `echo -e "$out"> ~/.gmail/.gmail_top`;
    }
    
    $pop->Close();
    i tried the linked thread but it contains nothing conky related

    Thanks, nick
    Last edited by Gargintua; January 21st, 2010 at 05:07 AM.

  4. #4
    Join Date
    Feb 2010
    Beans
    1

    Re: Conky mail script

    I had same problem, because the perl module is needed to install it type:
    Code:
    cpan -i Mail::POP3Client

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •