From: Gunnar Hjalmarsson <nore...@gunnar.cc> > Steve Bertrand wrote: > > Fúlvio Figueirôa wrote: > >> I solved my problem using sendmail with the code below: > >> > >> open (MAIL, "|/usr/sbin/sendmail -t "); > >> print MAIL "From: someaddr...@somedomain\n"; > >> print MAIL "To: someaddre...@somedomain\n"; > >> print MAIL "Content-Type: text/plain\n"; > >> print MAIL "Subject: Very simple email test\n\n"; > >> print MAIL "Body of the message"; > >> close (MAIL); > > > > I've had issues with doing things this way in the past. From my > > experience with the above code, if there is a fault, the message will > > not be sent, nor will it be queued to be sent later. Depending on the > > situation, not having the program follow proper SMTP protocol could be a > > problem if a message is not delivered, and there is no trace of it in > > any queue. > > > > Perhaps someone here can verify that there is a workaround, but I would > > highly recommend at least handing off the message so that a proper MTA > > can take care of any network-type issues for you, even if the MTA is on > > the localhost. > > That comment confuses me. AFAIK, sendmail *is* an MTA (mail transfer > agent), which e.g. handles queuing, and the above code passes a message > to sendmail. I also believe that there are built-in defaults in sendmail > that help you conform to certain aspects of the SMTP protocol.
sendmail is both an MTA and a commandline program for handing stuff over to the MTA. The problem with this way to sending emails from scripts is that it's hard to handle the errors reported directly by the sendmail commandline program. Once this step succeeds, the email is gonna be kept in the queue, retried etc. But if the sendmail refuses the email right away, you'll never know. You'd have to check the return value of the close(MAIL) to find out whether it succeeded and capture and parse the /usr/bin/sendmail's STDERR to know what failed. It's generaly safer to leave this to a module. Either one that calls the /usr/bin/sendmail in such a way that you do get the error info or one that contains the MTA via SMTP, not via the commandline program. Jenda ===== je...@krynicky.cz === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/