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