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

Hi, I am unable to send mail using the Mail::Sendmail. when i run the following script it's not showing any error message.
use Mail::Sendmail; my $message = <<HTML; Thanks For Using.<br >Best Regards,<br >Sachin HTML my $mdate = Mail::Sendmail::time_to_date( time() - 86400 ); $message .= $mdate; my %mail = ( From => 'sachin_bca@live.com', To => 'sachin_bca@live.com', Subject => "Subject: Test Mail\n", Message => $message, 'Content-type' => 'text/html; +charset="iso-8859-1"' ); sendmail(%mail) || print STDERR "Error sending mail: $Mail +::Sendmail::error\n";
Please tell me whats the problem with the script.

Replies are listed 'Best First'.
Re: Unable to send mail using Mail::Sendmail?
by almut (Canon) on May 13, 2010 at 10:14 UTC
    it's not showing any error message

    You could enable debugging:

    use Mail::Sendmail qw(sendmail %mailcfg); $mailcfg{debug} = 6;
Re: Unable to send mail using Mail::Sendmail?
by scorpio17 (Canon) on May 13, 2010 at 15:19 UTC

    Mail::Sendmail depends on your having a working SMTP mail server. If you don't explicitly tell it what to use, I think it defaults to 'localhost'. So you might need to add something like this:

    use Mail::SendMail; $Mail::Sendmail::mailcfg{smtp} = ['smtp.your_server.com'];

    Of course, you should insert the name of your actual smtp server.