Server Class |
Namespace: SMTPRouter
The Server type exposes the following members.
| Name | Description | |
|---|---|---|
| Server |
Initializes a new instance of the Server
| |
| Server(String, Int32, Boolean, Boolean, String, String) |
Initializes a new Server Instance
| |
| Server(String, Int32, Boolean, Boolean, String, String) |
Initializes a new Server Instance
|
| Name | Description | |
|---|---|---|
| DestinationSmtps |
A Dictionary containing the Smtp Configuration based on a Key name
| |
| Folders |
A structure representing the queue folders
| |
| IsPaused |
Defines whether the routing process is Paused or Running
| |
| Listener |
Reference to the Listener used by the Server
| |
| MessageLifespan |
The TimeSpan a message is stil considered valid. By default, a message lasts 15 minutes after its creation time
| |
| MessagePurgeLifespan |
The TimeSpan a message remains on queues. By default a message remains there for 90 days before being purged.
| |
| Ports |
Ports where the SMTP Service will be available
| |
| QueueName |
The name of the queue
| |
| QueuePath |
The root directory where the queues will be located
| |
| RequiresAuthentication |
Defines whether the SMTP Requires authentication
| |
| Router |
Reference to the Router used by the Server
| |
| RoutingRules |
List of Rules to be applied when routing messages
| |
| ServerName |
Name of the Server where the services will run
| |
| UseSSL |
Defines whether it's necessary to use SSL or not
|
| Name | Description | |
|---|---|---|
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
| GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| StartAsync | ||
| ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
| GeneralError |
Event triggered when a general error happens on the processing
| |
| ListeningStarted |
Event triggered when the Listener started to listen to smtp messages
| |
| MessageNotRouted |
Event triggered when a message could not be routed successfully
| |
| MessagePurging |
Event triggered when a message is about to be purged by the system.
| |
| MessageReceived |
Event triggered when a message is received
| |
| MessageRoutedSuccessfully |
Event triggered when a message is routed successfully
| |
| MessagesPurged |
Event triggered after messages are purged
| |
| SessionCommandExecuting |
Event trigered when a SMTP Command is being executed
| |
| SessionCompleted |
Event triggered when a SMTP Session is closed
| |
| SessionCreated |
Event triggered when a SMTP Session is created
|
// Creates the Server var server = new SMTPRouter.Server("localhost", 25, false, false, "SMTPRouter", "C:\\SMTPRouter\\Queues") { MessageLifespan = new TimeSpan(0, 15, 0), RoutingRules = new List<Models.RoutingRule>() { new Models.MailFromDomainRoutingRule(10, "gmail.com", "gmail"), new Models.MailFromDomainRoutingRule(20, "hotmail.com", "hotmail") }, DestinationSmtps = new Dictionary<string, Models.SmtpConfiguration> { { "gmail", new Models.SmtpConfiguration() { Host = "smtp.gmail.com", Description = "Google Mail SMTP", Port = 587, RequiresAuthentication = true, User = "user@gmail.com", Password = "", } }, { "hotmail", new Models.SmtpConfiguration() { Host = "smtp.live.com", Description = "Hotmail SMTP", Port = 587, RequiresAuthentication = true, User = "user@hotmail.com", Password = "", } } }, }; // Hook Events server.SessionCreated += Server_SessionCreated; server.SessionCommandExecuting += Server_SessionCommandExecuting; server.SessionCompleted += Server_SessionCompleted; server.ListeningStarted += Server_ListeningStarted; server.MessageReceived += Server_MessageReceived; server.MessageRoutedSuccessfully += Server_MessageRoutedSuccessfully; server.MessageNotRouted += Server_MessageNotRouted; // Initialize Services Task.WhenAll(server.StartAsync(CancellationToken.None)).ConfigureAwait(false);