Mime::Lite module generating an error

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I can send email from my linux server with 'mailx' command. I could
also send an email from it using Mime::Lite module until recently.
Today the same old working module has started failing, and it gives an
error: Illegal Seek.
What could be happening?

The mailx cmd runs well: mailx -s "subject1 sub 2"
myname@mycompany.com <aaa

cmd: ./local-send-mail-test.pl
The error:
rv = 1, Illegal seek
An email, with subject: (sample subject), has been sent to myname-etc-

Code as below : (You will need to edit the line marked 'edit-this-
line' before running it.

use strict ;
use warnings ;

use MIME::Lite;

my $my_email = 'myname@mycompany.com' ;  ## edit-this-line
my $subject = 'sample subject' ;
my $message = "line 1, line 1" ;
my $msg_body_type = 'text' ;
my $msg = MIME::Lite->new(
        To => "$my_email",
        Subject => $subject,
        Type => 'multipart/related',
    Type => $msg_body_type,   #-# text/html or text
    Data => $message
my $rv = $msg->send() ;
print "rv = $rv, $! \n\nAn email, with subject: ($subject), has been
sent to $my_email\n\n" ;


Re: Mime::Lite module generating an error

On 2012-11-01 06:43, dn.perl@gmail.com wrote:

Quoted text here. Click to load it

You are printing "$!" for no good reason.

It is a special global variable, that can basically have any value.
You should only print that variable if you know that there was an error.
Now it is probably just about something that send() was trying.


Re: Mime::Lite module generating an error

Quoted text here. Click to load it


Quoted text here. Click to load it

Most likely, some code in the C libary called lseek on the underlying
file descriptor and this call failed because the file descriptor
referred to the write end of a pipe connecting your code to a sendmail
process and pipes are not seekable. $! is the Perl name for errno and
the current value of errno isn't generally meaningful except when some
system or C library call returned an error indication to the
caller. In this given case, unless ->send() returned 'false', no error
has occurred.

Site Timeline