use strict;
use warnings;
+
use Email::Send;
use Email::Folder;
+
my %received;
my $box = Email::Folder->new('/home/jonathan/mail/Recruiters/');
while ( my $mail = $box->next_message )
{
+
$mail->header_set('To','jonathan@localhost');
send SMTP => $mail->as_string(), 'localhost';
}
Of course fixing some of the values as appropriate.
/J\
| [reply] [d/l] |
thanks,
I'll give this a try and let you know.
| [reply] |
I have been looking at this for some time and need to handle email received from stdin via a pipe and bounce it somewhere else.
Can I just plug this in somehow into the Email::Folder and Email::Send stream?
| [reply] |
| [reply] |
thanks again gellyfish..
I've written the code similar to the way you show. I added some changes to the header modification to ensure that replies and replies to all work, and that the CC addresses in the message aren't copied on the remailed message.
This works great and was very easy.
I've been looking at the module and I don't see a way to only select new messages? I've tried giving Email::Folder->new only the new folder but the module complains that it's not an IMAP directory.
Is there a way to only process new messages? I'd like to add a command line option to only remail new messages rather than the entire inbox. Would I have to use another module to do this?
Any suggestions would be great
TIA,
chrisj
| [reply] |
You don't want to modify the body of the message at all. Use the existing content, completely unmodified (unparsed, etc, other than seperated into messages) as the message body, and use the new envelope-from and envelope-to in the SMTP transaction.
There is no reason to attempt to parse the message, unless there's some sort of information that you need to use to determine where to route the mesage to, if you really want it to be as close to the original as possible.
Now we come to the question -- do you really want it close to the original? If the mail program that's reading the messages sorts on the message's date, and not the received time of the message, this could cause some odd effects, as they might not realize that you've just inserted a couple hundred messages that were dated 3 years ago into their mailbox. Most modern mail readers don't have this problem, as they default to using the received time for their date sorting, but it's possible that this might be an issue.
Update: If people are going to suggest non-perl solutions, I might as well, too ... using pine, enable aggregate commands, and bounce command, then ;aab (or well, whatever selection criteria for the folder)
| [reply] [d/l] |
If you don't mind a non-perl solution, maildirsmtp from the serialmail package is designed to do nearly exactly what you want.
| [reply] [d/l] |
Could you not do this with sendmail? | [reply] |
| [reply] |