I'm using Mime::Lite in a Perl module that I'm running as a daemon via an init.d script. It was running fine until I upgraded Debian from squeeze to wheezy. Now I get this message when it finds an email message in my database to send.
2013-11-21 23:10:37 [MIME::Lite 13557] : **** DIE!!! **** error closin +g /usr/lib/sendmail: No child processes (exit -1) Additionally, an error occurred sending the alert email: error closin +g /usr/lib/sendmail: No child processes (exit -1) 2013-11-21 23:10:37 [Proc::PID::File 13557] : **** Permission denied a +t /usr/local/share/perl/5.14.2/Proc/PID/File.pm line 224 during globa +l destruction.
Here's the relevant code.
while (my $row = $get_sth->fetchrow_hashref) { if ($row->{messagetext} && $row->{messagehtml}) { if ($debug == 1) { $row->{recipient} = 'webdev@naplesrentals.com'; $msgcnt++; } my $status = 'sent'; my $message = new MIME::Lite( To => $row->{recipient}, From => $row->{sender}, Subject => $row->{subject}, Type => 'multipart/alternative'); $message->attach(Type=>'text/plain', Data=>$row->{messagetext}); $message->attach(Type=>'text/html', Data=>$row->{messagehtml}); $upd_sth->execute($status, $row->{messageid}); $message->send_by_sendmail or logmsg('Warning'); logmsg("Delivered message: MessageID: " . $row->{messa +geid}); } else { $upd_sth->execute('error', $row->{messageid}); logmsg("Invalid message: MessageID: " . $row->{message +id} . " Next!"); } }
And here's the code the starts the process.
sub start { my $self = shift; my $name = $self->name; if (my $pid = fork()) { # parent + + exit 0; } #Child + + if (Proc::PID::File->running({name=>$name})) { die "Couldn't start: '$name' already running."; } $self->init_mailer_daemon; }
The init_mailer_daemon function ...
sub init_mailer_daemon { my $self = shift; my $name = $self->name; print "Starting: '$name'\n"; *CORE::GLOBAL::warn = \&warn_to_log; $SIG{__DIE__} = \&die_to_log; $SIG{__WARN__} = \&warn_to_log; eval { chdir '/' or die $!; open STDIN, '/dev/null' or die $!; open(STDOUT, '>>' . $self->logfile); open(STDERR, '+>&STDOUT'); logmsg('Starting Listmanager'); POSIX::setsid or die $!; logmsg('Successful'); }; if ($@) { die "Couldn't start child '$name': $@"; } local $SIG{CHLD} = 'IGNORE'; &queue; }

In reply to Mime::Lite Sendmail Dying by halfbaked

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.