Anonymous Monk has asked for the
wisdom of the Perl Monks concerning the following question:
I am trying to write a smart mail router to collect mail from a POP3 server provided by our ISP and forward on to the intended recipients.
We occasionally receive email at our office that is misaddressed i.e it is sent to firstname.lastname@example.org instead of email@example.com - (the user missed a 'd' out of freddie).
Mail that is incorrectly addressed goes to a POP3 'catchall' account provided by our ISP. e.g firstname.lastname@example.org
I can collect email from this catchall account with POP3Client (OK),apply some guestimations to figure out where the mail was really supposed to go and then forward it on locally or remotely via SMTP.
The problem is that I cannot figure out how to reliably identify the recipients email address in the header of the original email I collect via POP3client.
The mail Header To: field is obviously unreliable ('Undisclosed ricipients' etc).
The topmost Received: field in the message Header contains an indented ' for <address>' that looks promising, but even this does not identify the genuine intended recipient where mails are sent to us by our ISP's list server (although in these cases the To: field is valid!).
Is there information loss from the Header when POP3 email is collected that makes the task impossible?
Is the unknown 'recipient for field' only going to be a problem with mail from our ISP's list server?
Is there a better way to do this, rather than collecting with a POP3 Client in the first place?
Any help much appreciated!