XMailforum is a readonly knowledge archive now.

Registering as a new user or answering posts is not possible anymore.

Might the force be with you, to find here what you are looking for.

2019-09-20 - hschneider, Admin

Cookie Disclaimer: This forum uses only essential, anonymous session cookies (xmailforum*), nothing to be scared of.

XMail Forum [Powered by Invision Power Board]
Printable Version of Topic
Click here to view this topic in its original format
XMail Forum > Documentation and Knowledge Base > reinjecting a message into the queue


Posted by: NomadCF Sep 8 2006, 04:18 PM
Heres the idea, I have a script that archives every message in and out (not spam or virus,etc). This file is copied directly from the spool dir fully intact (meaning with all the xmail headers in place). Now what I'm like to do is be able to re inject that copy back into the xmail spool.

I've tried just coping it into spool/temp (it just sat there)
I've tired copying it into spool/local (it errors out “invalid spool file”)

The closest thing I've got to work it by remove all the xmail headers from the copy expect the :
“MAIL FROM,RCPT TO,<<MAIL-DATA>>” hen the message is delivered but it logs a lot of errors about the message and the headers f.u.b.a.r.


So the question comes down to this how does one drop email into xmails queue for delivery ?

Posted by: hschneider Sep 9 2006, 06:22 AM
Inject a mail by placing a RFC-conform mail file into spool/local. Each line has to have DOS style line endings:

CODE

MAIL FROM: <...>\r\n
RCPT TO: <...>\r\n
\r\n
FROM: <...>\r\n
TO: <...>\r\n
SUBJECT: <...>\r\n
X-SOME-MORE-HEADER-FIELDS: ....\r\n
\r\n
\r\n
The mail's text body ...\r\n
\r\n


If you want to restore archived mails, it's wise to remove all RECEIVED headers, because this can cause looping mails.

Posted by: NomadCF Sep 9 2006, 07:11 AM
Thanks for the help, But I found it's only 1 return between the "RCPT TO:" and the headers. putting 2 return between then fubars the message and the server things the header are part of the body. But thanks for pointing me in the right Direction !!!

Posted by: hschneider Sep 9 2006, 07:15 AM
Yes - just went in to correct it, but you were faster :-)

Posted by: hschneider Sep 9 2006, 07:18 AM
One more thing:
If you are on Windows, using Perl, then you'll have to set the file's mode to binary before writing it:

CODE

open(FILE,'> '.$MAIL_ROOT.'/spool/local/'.time().rand(1000).'.txt') or &quit();
binmode(FILE);
print FILE $mail;
close(FILE);


Using the same code on other platforms doesn't matter.

Posted by: NomadCF Sep 9 2006, 07:30 AM
you'll probably not want to just use time & a ramdom number, but also include the scripts PID (on windows this is not easy but there is a gpl program to help with this : http://www.scheibli.com/v3/projects/getpids/).

But this to is not 100% safe due to windows liking to reuse PID's rather quickly.

I hope this doesn't come across as a being picky.

Posted by: hschneider Sep 9 2006, 07:45 AM
Good point, let's doit with time+random+pid wink.gif

Posted by: hschneider Sep 9 2006, 07:48 AM
Just noticed, that the getpid thing is an .exe file. This will cause an overhead because a shell process is started . This will slow things down, eating up resources. However, it's a brilliant idea to use it on other platforms ...

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)