Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (Config/IMAP): Explicit config to enable/disable IMAP server #833

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Rnwood.Smtp4dev/CommandLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static MapOptions<CommandLineOptions> TryParseCommandLine(string[] args)
{ "relaypassword=", "The password for the SMTP server used to relay messages", data => map.Add(data, x=> x.RelayOptions.Password) },
{ "relaytlsmode=", "Sets the TLS mode when connecting to relay SMTP server. See: http://www.mimekit.net/docs/html/T_MailKit_Security_SecureSocketOptions.htm", data => map.Add(data, x=> x.RelayOptions.TlsMode) },
{ "imapport=", "Specifies the port the IMAP server will listen on - allows standard email clients to view/retrieve messages", data => map.Add(data, x=> x.ServerOptions.ImapPort) },
{ "imapserverenabled=", "Boolean to determine if IMAP server should start, default is true", data => map.Add(data, x=>x.ServerOptions.ImapServerEnabled)},
{ "nousersettings", "Skip loading of appsetttings.json file in %APPDATA%", data => map.Add((data !=null).ToString(), x=> x.NoUserSettings) },
{ "debugsettings", "Prints out most settings values on startup", data => map.Add((data !=null).ToString(), x=> x.DebugSettings) },
{ "recreatedb", "Recreates the DB on startup if it already exists", data => map.Add((data !=null).ToString(), x=> x.ServerOptions.RecreateDb) }
Expand Down
8 changes: 7 additions & 1 deletion Rnwood.Smtp4dev/Server/ImapServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ public bool IsRunning

public void TryStart()
{
if (!serverOptions.CurrentValue.ImapServerEnabled)
{
log.Information("IMAP Server disabled");
return;
}

if (!serverOptions.CurrentValue.ImapPort.HasValue)
{
log.Information("IMAP server disabled");
log.Information("IMAP server disabled, no ImapPort specified");
return;
}

Expand Down
2 changes: 2 additions & 0 deletions Rnwood.Smtp4dev/Server/ServerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class ServerOptions

public int? ImapPort { get; set; } = 143;

public bool ImapServerEnabled { get; set; } = true;

public bool RecreateDb { get; set; }
}
}
5 changes: 4 additions & 1 deletion Rnwood.Smtp4dev/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
"TlsCertificate": "",

//Specifies the port the IMAP server will listen on - allows standard email clients to view/retrieve messages
"ImapPort": 143
"ImapPort": 143,

// Explicity enable/disable IMAP server, default is true
"ImapServerEnabled": true
},

"RelayOptions": {
Expand Down