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

Hi monks,

I am trying to send a mail using Mail::Sender module. The script is as follows
use Mail::Sender; $sender = new Mail::Sender {smtp => 'xxx.xxx.xxx.xxx', from => 'itsme@from.com'}; $sender->MailFile({to => 'tou@to.com', subject => 'Hi', msg => "Hello friend." });
I am not getting any error, but the mail is not being sent to the recipient.

Whats wrong with the script?

Thanks & Regards

Nalina

janitored by ybiC: Retitle from "Mail::Sender", as one-word nodetitles hinder site search

Replies are listed 'Best First'.
Mail::Sender, no errors, but no email either
by Random_Walk (Prior) on Aug 16, 2004 at 10:46 UTC
    Nalina,

    You have no file given in your MailFile call. It may be as simple as this. The following is a cut and paste from CPAN. Perhaps you should be using the MailMsg method instead.

    Cheers,

    use Mail::Sender; $sender = new Mail::Sender {smtp => 'mail.yourdomain.com', from => 'your@address.com'}; $sender->MailFile({to => 'some@address.com', subject => 'Here is the file', msg => "I'm sending you the list you wanted.", file => 'filename.txt'});
    and further down in the doc...
    MailMsg([from [, replyto [, to [, smtp [, subject [, headers]]]]]], me +ssage) MailMsg({[from => "somebody@somewhere.com"] [, to => "else@nowhere.com"] [...], msg => "Message"})
      Thanks for the reply. After posting to the forum, I realized that MailMsg should be used instead of MailFile if the file need not be attached.
Re: Mail::Sender, no errors, but no email either
by reneeb (Chaplain) on Aug 16, 2004 at 10:49 UTC
    You have to add a file:
    use Mail::Sender; $sender = new Mail::Sender {smtp => 'xxx.xxx.xxx.xxx', from => 'itsme@from.com'}; $sender->MailFile({to => 'tou@to.com', subject => 'Hi', msg => "Hello friend.", file => './path/to/file', });


    alternatively you can use this code (without an attachment - just a message):
    use Mail::Sender; $sender = new Mail::Sender; if ($sender->MailMsg({ smtp => 'mail.yourISP.com', from => 'somebody@somewhere.com', to =>'Jenda@Krynicky.czX', subject => 'this is a test', msg => "Hi Johnie.\nHow are you?" }) < 0) { die "$Mail::Sender::Error\n"; } print "Mail sent OK."

    If you want to attach something you can add it with $sender->Attach();

    see: http://search.cpan.org/~jenda/Mail-Sender-0.8.10/Sender.pm