Mime::Lite module generating an error


D

dn.perl

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"
(e-mail address removed) <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-
etc


Code as below : (You will need to edit the line marked 'edit-this-
line' before running it.
#!/usr/local/bin/perl

use strict ;
use warnings ;

use MIME::Lite;

my $my_email = '(e-mail address removed)' ; ## edit-this-line
my $subject = 'sample subject' ;
my $message = "line 1, line 1" ;
my $msg_body_type = 'text' ;
my $msg = MIME::Lite->new(
From=>$my_email,
To => "$my_email",
Subject => $subject,
Type => 'multipart/related',
);
$msg->attach(
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" ;

##=============
 
Ad

Advertisements

D

Dr.Ruud

my $rv = $msg->send() ;
print "rv = $rv, $! \n\nAn email, with subject: ($subject), has been
sent to $my_email\n\n" ;

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.
 
Ad

Advertisements

R

Rainer Weikusat

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?
[...]

my $rv = $msg->send() ;
print "rv = $rv, $! \n\nAn email, with subject: ($subject), has been
sent to $my_email\n\n" ;

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top