Add Support for forwarding .eml files
SMTP email proxy and relay server
Brought to you by:
graeme_walker
Hi Graeme,
Could you please add a way or advise a way for me to bypass the built in email parsing which would allow me to forward .eml files directly to a relay, I don't use the program to accept incoming emails and would only need to send .eml files to a relay after they have been generated and dropped into a folder.
The normal way to do it would be to use the emailrelay-submit utility. It takes a RFC-822 content file, copies it into the emailrelay spool directory and adds an envelope file. I would expect that to work just fine with .eml files as input. Does that work for you?
Using the emailrelay-submit function just seems to lock up my command prompt in an input window, when inputting under the command it does create a .content file but theres no automatic content file generation from the .eml files already in the folder, there's no documentation on the submit function as far as i can tell so I'm using the arguments "emailrelay-submit --spool-dir MySpoolDir MyRelayAddress:25", what i'm trying to do is recreate the functionality of IIS smtp server's file pickup and forward the emails in the directory to a relay that I host.
When you run emailrelay-submit at a command prompt it expects the email content to be on the standard input -- that means typed in from the keyboard or taken from a file using "<" redirection or from a "|" pipline.
So something like this:
Without the "<" redirection it will wait forever for you to type in the message. (For basic usage information use "emailrelay-submit --help -v".)
So to get your "file drop" functionality you would need a script, probably run as a "scheduled task", that looks for ".eml" files in the file-drop folder that are more than a few seconds old, runs emailrelay-submit and then deletes them if emailrelay-submit was successful (exit code zero). You could even use the emailrelay spool directory itself as the file-drop folder because emailrelay ignores files with unexpected filenames.
One complication is that emailrelay-submit requires a list of 'to' addresses on the command-line, which you would have to parse out of the content file. These are "envelope to"s and not "content to"s. The difference is that Bcc: addresses in the content file should result in a separate message for each addressee, which non-addressee addresses stripped out. This is something that emailrelay-submit should probably do for you -- I'll see what I can do.
Another thing I have considered for a while is having a new "--poll-action" mechanism where emailrelay calls the user's script every time the "--poll" timer expires. In your case what would mean you would not have to set up a scheduled task.
Thanks for the insight, I have a basic powershell script that could be scheduled that is working for me, the emails do not have any cc addresses detailed so I haven't looked into a way around that problem. I have attached the script in-case anyone in future has a similar issue or request. A --poll-action argument would be useful however this will work fine for me for the moment.
I'm glad it's working out for you. The next release of the emailrelay-submit tool should mean you don't have to parse out the recipient's envelope address.