From: Daniel Staal <[EMAIL PROTECTED]> > --As of Tuesday, February 17, 2004 4:58 PM +0200, John is alleged to > have said: > > > Here is my code > > Thanks. ;-) > > >#!/usr/bin/perl -w > > use strict; > > > use Mail::Sender; > > $sender = new Mail::Sender({smtp => 'mymailserver', from => > > '[EMAIL PROTECTED]'}); > > $sender->MailFile({to => '[EMAIL PROTECTED]', > > subject => 'Here is the file', > > msg => "I'm sending you the list you wanted."}); > > > > > > john, john2 usernames exist on the mymailserver (it runs ESMTP > > Sendmail 8.9.3/8.9.3) > > Well, you are missing a 'send' call; Mail::Sender has several you can > choose from, depending on your needs.
Actually not. The MailFile method does create and send the message, no need for any further method calls. The problem is that John did not check for errors. The easiest way (IMHO) is to ask Mail::Sender to throw an exception if there is a problem: $sender = new Mail::Sender({ smtp => 'mymailserver', from => '[EMAIL PROTECTED]', on_errors => 'die', }); > By the way, as others pointed out Mail::Sender is very low-level. I > would suggest a higher level module here. MIME::Lite is highly > regarded, and often overlooked while searching... I think you confuse Mail::Sender and Net::SMTP. Mail::Sender and MIME::Lite is at about the same level. The big difference is in the philosophy of the modules. In MIME::Lite you are constructing a message and then when it's complete, with all the parts and files, you send it as one object. In MIME::Lite the message is the object. OTOH in Mail::Sender, you are controling a mail agent, you tell it to connect to a server and start a multipart mail, then you tell it what to send as the body, what file to attach and then to close the message. And the sender does each of those actions immediately. (Except if you use the MailMsg or MailFile shortcuts that do all these actions behind the scenes.) Which means Mail::Sender uses less memory if you are attaching big files, but if you need more complex multipart messages its interface is not that nice. And overall Mail::Sender is a bit dirtier :-) Jenda ===== [EMAIL PROTECTED] === 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>