cosullivan / SmtpServer

A SMTP Server component written in C#
MIT License
676 stars 160 forks source link

MessageStore breaking changes? #143

Closed reponemec closed 3 years ago

reponemec commented 3 years ago

It looks SmtpServerOptionsBuilder.MessageStore operation has been completely rewrited since 8.0.1 version of SmtpServer.

Old: new SmtpServerOptionsBuilder().MessageStore(new SampleMessageStore());

New: serviceProvider.Add(new SampleMessageStore());

Seems significant breaking changes comparing with 7.0.2. Is there any updated readme.md about "How can it be used?" And which version of package you recommend me should I use? I experimented with 7.0.2 for a long time, but it looks its startup API will be replaced with the new one.

cosullivan commented 3 years ago

Hi,

Yes, version 8 does contain some breaking changes mostly around performance, but also around improving extensibility. I am still working through this document which will describe the changes and hope to have that complete in the next week or two. https://github.com/cosullivan/SmtpServer/blob/master/Version8.md

If you need to reference how the changes work, all of the sample where applicable have been updated but realistically the differences are mostly around how the services are configured along with the fact that the IMessageStore now receives a ReadOnlySequence versus a stream. The effort to migrate from 7 to 8 should be minimal.

The SmtpServerOptionsBuilder is now specifically just for the options, whereas the services such as IMessageStore, IMailboxFilter, IUserAuthenticator are now supplied via the IServiceProvider which works better for Dependency Injection, see here for an example; https://github.com/cosullivan/SmtpServer/blob/master/Examples/WorkerService/Program.cs

Thanks, Cain.

reponemec commented 3 years ago

OK, thanks.

cosullivan commented 3 years ago

I've updated the doco here; https://github.com/cosullivan/SmtpServer/blob/master/Version8.md