This project has moved and is read-only. For the latest updates, please go here.

How do I configure service to write eml files to specific folder

Aug 13, 2014 at 11:28 AM
Edited Aug 13, 2014 at 12:13 PM
How do I configure service to write eml files to specific folder.

What would I set inside the json config file for the service?

I want to organise the files and folders :-

..\bin - binary files and config
..\data - incoming email files

works with the client if I set
  <setting name="MessagePaths" serializeAs="String">
    <value>..\data</value>
  </setting>
but ignored by service, it just dumps eml files in same folder as it lives in.
Aug 14, 2014 at 4:34 PM
I would also like this. Is there a way to add it to the settings window?
Aug 15, 2014 at 3:55 AM
Edited Aug 15, 2014 at 3:57 AM
Yes, please use this Papercut.Settings.json file as a guide:
{
    // Specific Path to Save Incoming Messages, default is "BaseDirectory\\Incoming"
    "MessagePath": "%BaseDirectory%\\incoming",

    // SMTP SETTINGS
    //      
    "IP": "Any", // IP to Bind, default is "Any" (0.0.0.0)      
    Port: 25    // Port to Bind, default is "25"
}
I beefed up the incoming message path handling code tonight -- will be a bit better in the next release coming very soon.
Aug 15, 2014 at 10:08 AM
Does this new JSON setting work now?
I tried entering "MessagePath" in the json file.
{
    "MessagePath": "..\data"
}
But this is ignored
Aug 15, 2014 at 10:14 AM
Edited Aug 15, 2014 at 10:27 AM
My mistake I forgot to escape the \ path separator character, which results in the setting being erased ...

Correct syntax which I have found to work is
{
  "MessagePath": "..\\data"
}
Might be an idea to push the logs (both service and app) to a specific path as well, just to keep the application folder "clean"
Aug 15, 2014 at 11:29 AM
Just found out that the setting ONLY works when the service exe is run via the cmd prompt

Log when running in cmd prompt
2014-08-15 11:17:38.195 +01:00 [Information] Configuration Result:
"[Success] Name PapercutServerService
[Success] DisplayName Papercut SMTP Service
[Success] Description Papercut SMTP Backend Service
[Success] ServiceName PapercutServerService"
2014-08-15 11:17:38.366 +01:00 [Information] "Topshelf" v"3.1.122.0", .NET Framework v"4.0.30319.18444"
2014-08-15 11:17:39.054 +01:00 [Debug] "Running as a console application, creating the console host."
2014-08-15 11:17:39.070 +01:00 [Debug] "Starting up as a console application"
2014-08-15 11:17:39.101 +01:00 [Information] Publishing PapercutServicePreStartEvent { AppMeta: ApplicationMeta { AppName: "Papercut.Service", AppVersion: "4.1.0" } } to the Papercut Client
2014-08-15 11:17:40.382 +01:00 [Information] The "PapercutServerService" service is now running, press Control+C to exit.
2014-08-15 11:17:41.398 +01:00 [Information] Starting Server Papercut
2014-08-15 11:17:41.398 +01:00 [Information] Starting Server Smtp
2014-08-15 11:17:41.413 +01:00 [Information] Server Ready - Listening for New Connections "0.0.0.0":25
2014-08-15 11:17:41.413 +01:00 [Information] Server Ready - Listening for New Connections "127.0.0.1":37403
2014-08-15 11:17:41.445 +01:00 [Information] Publishing PapercutServiceReadyEvent { AppMeta: ApplicationMeta { AppName: "Papercut.Service", AppVersion: "4.1.0" } } to the Papercut Client
2014-08-15 11:18:07.397 +01:00 [Debug] Message Load Path Templates are ["C:\Tools\Papercut-4.1.0.0\data"]
2014-08-15 11:18:07.397 +01:00 [Information] Default Message Save Path is Set to "C:\Tools\Papercut-4.1.0.0\data"
Log when running as service
2014-08-15 11:18:46.583 +01:00 [Information] Configuration Result:
"[Success] Name PapercutServerService
[Success] DisplayName Papercut SMTP Service
[Success] Description Papercut SMTP Backend Service
[Success] ServiceName PapercutServerService"
2014-08-15 11:18:46.755 +01:00 [Information] "Topshelf" v"3.1.122.0", .NET Framework v"4.0.30319.18444"
2014-08-15 11:18:47.458 +01:00 [Debug] "Started by the Windows services process"
2014-08-15 11:18:47.458 +01:00 [Debug] "Running as a service, creating service host."
2014-08-15 11:18:47.458 +01:00 [Information] "Starting as a Windows service"
2014-08-15 11:18:47.458 +01:00 [Debug] "[Topshelf] Starting up as a windows service application"
2014-08-15 11:18:47.474 +01:00 [Information] "[Topshelf] Starting"
2014-08-15 11:18:47.474 +01:00 [Debug] [Topshelf] Current Directory: "C:\Tools\Papercut-4.1.0.0"
2014-08-15 11:18:47.474 +01:00 [Debug] [Topshelf] Arguments: ""
2014-08-15 11:18:47.505 +01:00 [Information] Publishing PapercutServicePreStartEvent { AppMeta: ApplicationMeta { AppName: "Papercut.Service", AppVersion: "4.1.0" } } to the Papercut Client
2014-08-15 11:18:48.755 +01:00 [Information] "[Topshelf] Started"
2014-08-15 11:18:49.755 +01:00 [Information] Starting Server Papercut
2014-08-15 11:18:49.771 +01:00 [Information] Starting Server Smtp
2014-08-15 11:18:49.771 +01:00 [Information] Server Ready - Listening for New Connections "127.0.0.1":37403
2014-08-15 11:18:49.771 +01:00 [Information] Server Ready - Listening for New Connections "0.0.0.0":25
2014-08-15 11:18:49.802 +01:00 [Information] Publishing PapercutServiceReadyEvent { AppMeta: ApplicationMeta { AppName: "Papercut.Service", AppVersion: "4.1.0" } } to the Papercut Client
2014-08-15 11:19:00.317 +01:00 [Debug] Message Load Path Templates are ["C:\Tools\Papercut-4.1.0.0\data"]
2014-08-15 11:19:00.333 +01:00 [Information] Default Message Save Path is Set to "C:\Tools\Papercut-4.1.0.0\"
Aug 18, 2014 at 4:46 AM
Yeah, that was a bug. Fixed in latest.