Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Email form letters

by sz (Friar)
on Aug 04, 2000 at 19:29 UTC ( #26208=perlquestion: print w/replies, xml ) Need Help??

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

Hello perl monks,

Lately, at work, I've had to send a series of personalized emails to groups of people; essentially form letters. The personalized data comes from an Access database and I've cut and pasted the relevant records into each persons email, an incredible waste of time.

I'd like to automate this with Perl. If I was working from home (Linux) this would be fairly trivial. At work, however, I'm forced to use Win98. I can pull the data I need from Access using WIN32::ODBC. The question is: how to I send the emails? Is there a a windows counterpart to sendmail? Ideally, I'd like to create a simple email template system that would output to individual emails. I would appreciate any advice.

Thanks for your time.

Sergej

Replies are listed 'Best First'.
RE: Email form letters
by Odud (Pilgrim) on Aug 04, 2000 at 19:39 UTC
    You could use Net::SMTP to talk to your mail server (Exchange at a guess) - this should work fine although I haven't done this myself from W98. I've used Net::SMTP to talk from Unix to an Exchange server and this works fine. There is an example in the Windows Specifics documentation for ActiveState. If you don't have access to this let me know and I will send it to you.
RE: Email form letters
by nuance (Hermit) on Aug 04, 2000 at 19:40 UTC
    Have you considered using a word mail merge? It might just save you an awful lot of time.

    Update: See below, this is a really bad idea (one of my worse ones).

    Nuance

      I agree with that.
Re: Email form letters
by sz (Friar) on Aug 05, 2000 at 00:14 UTC
    Just a follow up...

    Using the example (below)in the Active State docs suggested by Odud, I get a "Bad command of file name" error from DOS. The email, however, is sent normally.

    Stepping through the code in the debugger, I see that the error is trigged by line 5, which initializes the smtp connection. I realize this may be as much a Win98 question as a Perl one, but I'm hoping someone can explain it to me. Thanks again for all your help.

    use Net::SMTP;
    
    $smtp = Net::SMTP->new('xp.psych.nyu.edu'); # connect to an SMTP server
    
    $smtp->mail( 'zoubok@psych.nyu.edu' );  # use the sender's address here
            
    $smtp->to('szoubok@flexdesigns.com'); # recipient's address
    
    $smtp->data();  # Start the mail
    
    # Send the header.
    #
    $smtp->datasend("To: szoubok\@flexdesigns.com\n");
    $smtp->datasend("From: zoubok\@psych.nyu.edu\n");
    $smtp->datasend("\n");
    
    # Send the body.
    $smtp->datasend("Hello, World!\n");
    
    $smtp->dataend();  # Finish sending the mail
    $smtp->quit;       # Close the SMTP connection
    
Re: Email form letters
by merlyn (Sage) on Aug 05, 2000 at 01:45 UTC
Re: Email form letters
by eak (Monk) on Aug 04, 2000 at 19:45 UTC
    You should be able to send mail from Win98 (but I haven't tried it in that OS) using Net::SMTP. It provides a client interface to the SMTP protocol. --eric
Re: Email form letters
by sz (Friar) on Aug 04, 2000 at 20:07 UTC
    Thanks everyone.

    I'll try Net::SMTP and search the Active State docs as well.

    nuance-- do you mean email directly from a Word mail merge? How?

    Best,

    Sergej
      Well, since you asked I went and checked it out. You can't easily send email to lots of recipiants from word :-(

      I remembered that you can send a document as email, but it looks like you can't automate it easily. Of course, if you going to have to go to the bother of writing a Word macro, then a perl solution is going to be better.

      Basically what it comes down to is I was wrong :-(

      Nuance

Re: Email form letters
by Anonymous Monk on Aug 05, 2000 at 02:13 UTC
    We use blat, which is freeware available from various places, including http://www.interlog.com/~tcharron/blat.html. It makes all the smtp calls for you, you just call blat from perl with the appropriate parameters.
Re: Email form letters
by Anonymous Monk on Aug 05, 2000 at 08:50 UTC
    Perhaps you might try looking in your ActivePerl online documentation Try Start/Programs/ActivePerl/Documentation. Check out the ActivePerl FAQ - Windows 9X/NT/2000 and try the question: How do I send email from ActivePerl? It's in the file ActivePerl-Winfaq4.html I hate to say it, but RTFM.
Sending email from Win98
by infinityandbeyond (Sexton) on Aug 05, 2000 at 07:59 UTC
    Try using Mail::Sendmail if you're using windows. - Infinityandbeyond
Re: Email form letters
by sz (Friar) on Aug 07, 2000 at 18:06 UTC
    Thanks again for the additional options. Off I go to test them...

    As for the AM suggestion that I RTFM, he/she should note my follow-up post. The example I used above to test Net::SMTP is, as I noted, precisely from the ActivePerl FAQ. Nonetheless, good advice.

    Thanks,

    Sergej

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://26208]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2022-05-21 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?