rnj has asked for the wisdom of the Perl Monks concerning the following question:

I have been using a program modified from Perl Cookbook by Christansen and Torkington (1998) to send myself reminder emails from my own computer to same computer. These emails have shown up in mutt and alpine. Now I have switched to Thunderbird but apparently it does not read /var/spool/mail. Any suggestions for a solution?

#!/usr/bin/perl -w # # ~/CRON/email-reminder-1.0.pl # # NB Sendmail slow with lan off, i.e. 5 mins. # # 20130720 # 20120108: email-reminder.pl # Cookbook p650 # # Uses file ~/DATES to check for Birthdays, Weddings, # Doctors, and Appointments. If finds any in 7days sends email to # ANOther@computer.home.net # # 20120111: email-reminder-1.0.pl updated to change # check for Doctors at 3 days # # DATES format "January x Birthday|Wedding|Doctor|Appointment" # # $blank=" "; $_=`date --date="+7 day" +%B,%_d`; s/, / /; s/,/ /; chomp; $match=$_.$blank; open (DOT_CAL,"/home/ANOther/DATES"); while (<DOT_CAL>){ if (/$match/){ if (/Birthday|Wedding/){ $Reminder=$_; mail_reminder() }else{ } } } close (DOT_CAL); $_=`date --date="+3 day" +%B,%_d`; s/, / /; s/,/ /; chomp; $match=$_.$blank; open (DOT_CAL,"/home/ANOther/DATES"); while (<DOT_CAL>){ if (/$match/){ if (/Doctor|Appointment/){ $Reminder=$_; print "D2 DATES[]= ",$_," Doctor or Appointment match \n"; mail_reminder() }else{ } } } close (DOT_CAL); sub mail_reminder{ use Mail::Mailer; $New_Reminder="Reminder"; $From_address="ANOther@computer.home.net"; $To_address="ANOther@192.168.1.171"; $mailer = Mail::Mailer->new(); $mailer->open({ From =>$From_address, To =>$To_address, Subject =>$New_Reminder, }); print $mailer $Reminder; print "we arrived here\n"; print "mailer= ",$mailer," Reminder= ",$Reminder,"\n"; $mailer->close() or die "Can't send: $!\n"; }

Replies are listed 'Best First'.
Re: Mail::Mailer and Thunderbird
by hippo (Archbishop) on Apr 21, 2015 at 21:40 UTC
    Now I have switched to Thunderbird but apparently it does not read /var/spool/mail.

    You've been misinformed. Thunderbird will quite happily read from a local mail spool.

Re: Mail::Mailer and Thunderbird
by ww (Archbishop) on Apr 21, 2015 at 21:48 UTC

    Do you have T'bird configured to do so?


    Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
    1. code
    2. verbatim error and/or warning messages
    3. a coherent explanation of what "doesn't work actually means.
Re: Mail::Mailer and Thunderbird
by Aldebaran (Curate) on Apr 22, 2015 at 19:39 UTC

    You'll find that you get more out of these forums by giving smaller examples of working code and building up from there. This one is simply hard on the eyes and does not avail itself of the use strict; and use warnings; pragmas (pragmata?), which can make the gurus grumpy, as it inhibits their ability to divine what's going on with your situation. I stripped this down to bare bones just to see what I'd get:

    $ perl mail1.pl No real MTA found, using 'testfile' at /usr/local/share/perl/5.14.2/Ma +il/Mailer.pm line 108. we arrived here mailer= Mail::Mailer::testfile=GLOB(0x91baf7c) Reminder= Feed Dino be +fore you go to the quarry. $

    I don't know what an MTA is, but I'd imagine that the complaint centers around the e-mails being made up. I did, however, single-quote them, so that the @ sign wouldn't be interpolated, as happens with double-quoting.

    use strict; use warnings; my $Reminder = "Feed Dino before you go to the quarry."; mail_reminder(); sub mail_reminder{ use Mail::Mailer; use strict; my $New_Reminder="Reminder"; my $From_address='fred@192.168.1.171'; my $To_address='barney@192.168.1.171'; my $mailer = Mail::Mailer->new(); $mailer->open({ From =>$From_address, To =>$To_address, Subject =>$New_Reminder, }); print $mailer $Reminder; print "we arrived here\n"; print "mailer= ",$mailer," Reminder= ",$Reminder,"\n"; $mailer->close() or die "Can't send: $!\n"; }

    Mail::Mailer keeps your abortive attempts in a file for you:

    $ cat mailer.testfile === test 1 Wed Apr 22 12:16:00 2015 from: twain@twain-desktop to: barney@192.168.1.171 Subject: Reminder To: barney@192.168.1.171 From: fred@192.168.1.171 Feed Dino before you go to the quarry.$

    Ultimately, I decided that this is not how I communicate in this day and age. Of the many things perl does, I don't want it to be an e-mail client when thunderbird, facebook, and cell phone messaging are the alternative.

      I don't know what an MTA is

      Mail Transport Agent. That piece of software that makes your mail travel from one computer to the other. Something like exim or sendmail. MTAs talk SMTP on TCP port 25.

      The other abbreviations you frequently see in the context of mail handling are:

      MUA, Mail User Agent
      This is the software that lets you read and write mails. Thunderbird, in this case, or elm, pine, mail.
      MSA, Mail Submission Agent
      The software that accepts mails from the MUA and transfers it to the MTA. "Outgoing mail server". This function is often integrated with the MTA. Sendmail is (or once was) so dominant that many other MSAs and MTAs have a compatibility executable called sendmail that accepts sendmail most common options for submitting emails. MSAs talk SMTP on TCP port 587.
      MDA, Mail Delivery Agent
      The software that stuffs your mail into your mailbox. Typically procmail or maildrop, invoked by the final MTA.
      MRA, Mail Retrieval Agent
      Software that polls a remote mail server, fetches mails and either deliver the mails locally or re-submit it to a (local) mailserver. This is completely optional. Typical implementations are getmail and fetchmail.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)