cosullivan / SmtpServer

A SMTP Server component written in C#
MIT License
675 stars 159 forks source link

Please i have a problem when I deploy my Server in docker #190

Closed cedricnguemo3 closed 8 months ago

cedricnguemo3 commented 1 year ago

indeed, when I launch my server in localhost I manage to intercept incoming emails. but when I expose this on docker I really have difficulty testing. and also I have trouble reading the content of my mail. thank you for helping me please.

BrewingCoder commented 1 year ago

When you use docker to launcher your server or worker process you need to EXPOSE the ports in your docker config. If you're using visual studio take a look at this: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/docker/visual-studio-tools-for-docker?view=aspnetcore-7.0

You simply want to expose whatever endpoints you've got setup for your smtp config.

As far as reading emails, the server doesn't really 'read' emails for you. You must create your own MessageStore class and use it to persist those emails somewhere (DB, File, Etc) then write something that reads that.

For info on the MessageStore take a look at the example: https://github.com/cosullivan/SmtpServer/blob/master/Examples/SampleApp/SampleMessageStore.cs