Thursday, August 21, 2003

Wow that was exciting. My post with the link to my .pl file was up for three seconds I swear and I got 1000 email messages. Whoops, last time I'll assume human intervention is unnecessary.
comment []2:56:18 PM  trackback []   

A good day coding. I cracked open "Learning Perl" with the tantalizing prospect of making it to page 21. Page 21 is where you get to fool around with mailing folks. Well, I got to page 21 and what do you know, the sample code didn't work. Here's what did:

    $reply_to = "DONOTREPLY\@egrigg9000.com";
    $subject = "testing";
    $to_df = "egrigg9000\@yahoo.com";
    $body = "bad news: $somename guessed $someguess\n";
    open (SENDMAIL, "|/usr/sbin/sendmail -t");
    print SENDMAIL "To: $to_df\n";
    print SENDMAIL "From: $reply_to\n";
    print SENDMAIL "Subject: $subject\n";
    print SENDMAIL "Content-type: text/plain\n\n";
    print SENDMAIL "$body";
    close (SENDMAIL);

So, after tons of google searching on things like "perl sendmail @ help basic" and wading through CGI tutorials which overlapped, but not quite, I've found the working code.

The real discovery here is the need for an escape character before the @ sign in the email address variable (mine is called $to_df). This is after loads of witchdoctory thinking I had the headers in the wrong order. By the way, does anyone know how to turn line numbers on in emacs?

<this is where I put the link to the .pl script for three seconds before taking it down>

Of course, it only mails me (not you) anytime there's a false guess, as per the tutorial in the book. So you'll have to take my word that I get the mail. The correct answers for anyone not in the flinstones is "groucho"


comment []2:42:15 PM  trackback []