if ($MIME_entity->parts > 0) { for (my $i=0;$i<$MIME_entity->parts;$i++) { my $subEntity = $MIME_entity->parts($i); my $ignore_plain = 0; my $ignore_html = 0; $ishtml = "1" if $subEntity->mime_type eq 'text/html'; $ishtml = "0" if $subEntity->mime_type eq 'text/plain'; if (($subEntity->mime_type eq 'text/html') && ($ignore_html == 0)) { if (my $io = $subEntity->open("r")) { while (defined($_=$io->getline)) { $_ =~ s/"/\"/g; $body .= $_; } $io->close; $ignore_plain=1; } } if (($subEntity->mime_type eq 'text/plain') && ($ignore_plain=0)) { if (my $io = $subEntity->open("r")) { while (defined($_=$io->getline)) { $_ =~ s/"/\"/g; $body .= $_; } $io->close; $ignore_html=1; } } } } else { $body = join "", @{$MIME_entity->body}; } #### if (($to && ($to =~ /system_mail\@/)) && ($subject =~ /(mail failure|mail delivery failure|Mail delivery failed)/i && $body =~ /permanent error/i)) { Set_Mail_Failure($newfrom,$subject,$body); } #### sub Set_Mail_Failure { my ($_c_from,$_c_subject,$_c_body) = @_; $_temp_body = $_c_body; $_cntr = 0; foreach my $_lck (split /\015\012/, $_temp_body) { $_cntr++; $_lck =~ s/^\s+$//g; $_lck =~ s/\s+$//g; if ($_lck =~ /^To:/i) { ($_trash,$_actual_email) = split /\/, $_lck, 2; $_is_right_chk = $dbh->selectrow_array(qq{ SELECT `subscribed` FROM `reg_users` WHERE `email` = ? }, undef, $_actual_email); if ($_is_right_chk) { $_full_msg = $_c_subject . "\n\n" . $_c_body; $dbh->do (qq{ UPDATE registered_users SET subscribed = ?, mail_failure = ?, mail_failure_msg = ? WHERE email = ?}, undef, 0, 1, $_full_msg, $_actual_email); open(FILE,">>show_results.txt") or die "Could not open file... $!"; # Debug only print FILE "Found email to be $_actual_email - Now I'm ending this and exiting...\n"; # Debug only close(FILE); # Debug only last; $dbh->disconnect() if $dbh; exit; } else { next; } } else { next; } } # Debugging only.... not going to stay. open(FILE2,">show_email.txt") or die "Could not open file... $!"; print FILE2 "$_c_body"; close(FILE2); open(FILE,">>show_results.txt") or die "Could not open file... $!"; print FILE "I must have NOT found the email($_cntr lines)! I am fixing to exit!\nLast Line: $_lck\n"; close(FILE); exit; # Did not work, and since it was a error email, just ignore it and exit... } #### split /\015\012/, $_temp_body split /\cM\cJ/, $_temp_body split /\r\n/, $_temp_body