cosullivan / SmtpServer

A SMTP Server component written in C#
MIT License
690 stars 163 forks source link

SMTP Server did not deliver mails #193

Closed ShaunLeMouton closed 11 months ago

ShaunLeMouton commented 1 year ago

I used the sample project and I use the following code to start the server:

SimpleServerExample.Run();

then I send a message to the server via my smtpClient (I used the sample mail client) the server give the following answers:

Press any key to shutdown the server.
Session Created.
Command Executing.
EHLO: DomainOrAddress=TestPC1
Command Executing.
MAIL: Address=test@testcompany.de Parameters=
Command Executing.
RCPT: Address=xofowkwjthwk@lambsauce.de
Command Executing.
DATA
Command Executing.
QUIT

but I did not receive any mail at xofowkwjthwk@lambsauce.de

I don't no why. Does someone else have the same problem or/and know how to solve it?

BrewingCoder commented 1 year ago

The smtp server doesn't actually send emails. It receives them. Once it receives them you can chose what to do with the email message.

If you just want to send an email to yourself use MailKit and send an email via your ISP or mail provider.

If you want to use the server as a relay you need to actually write the code to ship off the email, again using MailKit.

ShaunLeMouton commented 1 year ago

Thanks for the answer. I was a little bit confused.

I won't use a ISP or mail provider.

Yes I want to use the server as a relay to send emails as a client to smtp server. Ther server receive the mail and relay them to as example to gmail or other adresses. Do you have some MailKit example to relay mails?

mleader1 commented 1 year ago

Create direct query against recipient MX server and send email direct using MailKit. We use this repo (thanks to the developer) and build distributed mail server for our own platform. So far it's been working great. (Except minor issues with teh SSL part which I may send through a request/question later)

Send email direct without ISP/mail provider is quite simple though:

https://www.emailarchitect.net/easendmail/sdk/html/dnslookup.htm

https://www.limilabs.com/blog/send-email-without-smtp-server-dns-lookup

Code snippet from Limilabs (which is another great open source mail server vendor) is very clear and straight forward, you don't have to use their component to do the query and send message. Just open source DnsClient.NET for query, and MailKit for sending email will be just fine.

Good luck

cosullivan commented 11 months ago

Closing this now.