in reply to sendmail with perl

In fact, I don't see a perl question at all. I think the answer somehow relates to the fact that the To: header is really part of the body of the message and the smtp "rcpt to:" command describes the actual recipients.

If you want to do this in a perl way, look at Net::SMTP and MIME::Lite. And if you want to really really avoid work, see Net::SMTP::OneLiner.

-Paul

Replies are listed 'Best First'.
Re^2: sendmail with perl
by mwhiting (Beadle) on May 23, 2007 at 19:19 UTC
    OK, I was a bit brief on the code that I actually use. Here's the perl code:
    $mailProg = "/usr/sbin/sendmail -t"; open (MAIL, "|$mailProg"); print MAIL "Date: $mailheader_date -0500\n"; print MAIL "To: $recipient\n"; print MAIL "From: $adminEmail\n"; print MAIL "Subject: Borrow Request\n"; print MAIL "***********************************\n"; (more print statements with the body of the msg in here) close (MAIL);

    So yes, it could be that I'm doing it the wrong way .... although this has worked for a long time on a lot of different servers. :)

    What call to the sendmail program would work then, if it should have something else for the envelope besides what's in the body?

      Yes, that works acceptably well. It's not wrong... It's not really perl though. And I definitely don't know how to send to more than one recipient that way. When I'm doing bigger jobs, I always use Net::SMTP. A lot of people like MIME::Lite too, so I'd check there. I believe it forks a sendmail in some modes.

      -Paul

        Are Net::SMTP & MIME::Lite installed by default with Perl 5?

        (Where would I look to find that out ... that's a question I often have before using a module. I need to not be something that has to be installed by the ISP later on - since they don't often like to do that).

        Michael