Resending Default Address Mailbox Email
Hi There,
We had a problem with an MX record on one of our alias domains and all email that should have been going to a remote mail exchanger has ended up in the default mailbox (around 400 emails).
Is there any way to resend or forward all of this mail in the default address mailbox to the "Envelope-To" address automatically?
Or am I doomed to do this manually :(.
Thanks in Advance.
-
Once the email is delivered to the inbox, you can't re-queue it. You would need to either 1) copy the mail files to the remote mail server, if stores email in a maildir format, or 2) manually re-forward the email 0 -
Hey Vanessa, Thanks for the response. I did a little digging whilst I was waiting and found an Exim re-queue Perl script here: https://github.com/Exim/exim/wiki/Redeliver. I combined this with a little shell script rather than modifying the Perl script to iterate through all files in the cur/ mail folder: #!/bin/bash FILES=/home/acccoutname/mail/cur/* for f in $FILES do echo "Processing $f email..." perl redeliver.pl "$f" done
And the corresponding redeliver.pl Perl script:my $file = shift || die "need file\n"; my $gto = shift; # global to. if present, override other per-email decision my $msg = ''; my $to = ''; my $from = ''; open(I, "<$file") || die "Can't open $file\n"; while () { if (/^From /) { if ($msg) { if ($to && $from) { do_mail($from, $to, $msg); } else { print STDERR "have a message but no recips\n"; } } else { print STDERR "saw From w/ no message\n"; } $msg = ''; $from = ''; $to = ''; } elsif (/^Return-path:\s*<(.*)>$/) { $from = $1; } elsif (/^Envelope-to:\s*(\S+)\s*$/) { $to = $1; } elsif (/^Delivery-date:\s*/) { ; # just ignore } else { $msg .= $_; } } close(I); if ($msg && $to && $from) { do_mail($from, $to, $msg); } sub do_mail { my $f = shift; my $t = shift; my $m = shift; $t = $gto if ($gto); print "$f -> $t\n"; #print "MAIL FROM:<$f>\nRCPT TO:<$t>\nDATA\n$m\n.\n"; open(P, "|/usr/lib/sendmail -f $f $t") || warn "can't open sendmail: $!\n"; print P $m, "\n.\n"; close(P); }
Both of these files are in the zip file attached. Nothing fancy but I hope this is of some use to anyone with the same problem .0 -
Hello :) I am happy to see you were able to find a solution. Thank you for updating us with the outcome. 0
Please sign in to leave a comment.
Comments
3 comments