rnwood / smtp4dev

smtp4dev - the fake smtp email server for development and testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NullReferenceException during Auto-Relay

sodermatt opened this issue · comments

I'm trying to get the Auto-Relay-Feature running.

I configured the following RelayOptions (Mail-Addresses, Server-Name are replaced with dummy-values)

`"RelayOptions": {

"IsEnabled": true,
"SmtpServer": "mail.domain.de",
"SmtpPort": 25,
"TlsMode": "Auto",
"AutomaticEmails": ["xyz@domain.de"],
"AutomaticRelayExpression": "recipient.match(/xyz@domain.de$/)",
"SenderAddress": "",
"Login": "",
"Password": ""
},`

When I submit a "Send-MailMessage"-PS, the mail is successfully delivered to smtp4dev, but the Auto-Relay throws an error.

Output in cmd-Window:

Session started. Client address ::1. Message received. Client address ::1, From abc@domain.de, To xyz@domain.de, SecureConnection: False. Processing received message AutomaticRelayExpression: (message: {message.Id}, recipient: 23cdcf12-29df-4f89-bc4e-700694f50291, session: {session.Id}) => xyz@domain.de => 04de849a-bf01-4745-81ca-660f90e887cd Relaying message to xyz@domain.de Can not relay message to xyz@domain.de: System.NullReferenceException: Object reference not set to an instance of an object. at Rnwood.Smtp4dev.Server.Smtp4devServer.TryRelayMessage(Message message, MailboxAddress[] overrideRecipients) in D:\a\1\s\Rnwood.Smtp4dev\Server\Smtp4devServer.cs:line 407 System.NullReferenceException: Object reference not set to an instance of an object. at Rnwood.Smtp4dev.Server.Smtp4devServer.TryRelayMessage(Message message, MailboxAddress[] overrideRecipients) in D:\a\1\s\Rnwood.Smtp4dev\Server\Smtp4devServer.cs:line 407 Processing received message DONE Session completed. Client address ::1. Number of messages 1.

Am I missing a Config-Option?

You can ignore that question. I am able to reproduce and will resolve this.

The ID is because there is a bug in the logging. It's the message ID.

Should be resolved by the PR.

Note that AutomaticEmails and the result of AutomaticRelayExpression will both apply are combined and the message is relayed to the distinct results for each origiinal recpient. So you don't need to configure both to match the same addresses. I guess you already know this and you're just testing?

So you don't need to configure both to match the same addresses. I guess you already know this and you're just testing?

Correct, this was just a test configuration - thanks for reacting this fast, really appreciated! Will test as soon as build is done