cosullivan / SmtpServer

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

What sender address when use SmtpClient? #158

Closed ahdung closed 3 years ago

ahdung commented 3 years ago

This is maybe a stupid question, forgive me please.

I use this started a server:

var options = new SmtpServerOptionsBuilder()
    .ServerName("localhost")
    .Port(25, 587)
    .Build();

var smtpServer = new SmtpServer.SmtpServer(options, ServiceProvider.Default);
await smtpServer.StartAsync(CancellationToken.None);

so how to set the sender address in SmtpClient?

cosullivan commented 3 years ago

Hi, this component is actually an SMTP Server, not an SMTP Client so you may be looking in the wrong place.

If you want an SMTP Client, check out https://github.com/jstedfast/MailKit

ahdung commented 3 years ago

I know this is a server, my question is when use client connect the server, what address I should type?

cosullivan commented 3 years ago

When you say the "sender address" are you referring to the sender's address of the email itself, or the address of the server you want to connect to?

If you are referring to the address of the server, then you would use the Smtp Client and connect to the IP address of the host machine that the SMTP Server is running on,.

If you are referring to the sender's address on the email, then that's irrelevant from the perspective of the SMTP server component.

Perhaps share more code to show what you are doing?

ahdung commented 3 years ago

Sorry my English is not good. Actually my purpose is send mail without provider account, so I want integrate a SMTP server into my app, and send mail to users by the App self, without using gmail/outlook or other else, so when I started a SmtpServer, how to send mail directly? Thank you.

cosullivan commented 3 years ago

Ok, I don't think this will suit your needs. This SMTP Server wont act as a relay server which is what you need by the sounds of it.

This is just designed to handle the communications with a Mail Client.

ahdung commented 3 years ago

Do you mean this server can't really send a mail to someone?

cosullivan commented 3 years ago

Yes, that is correct.

ahdung commented 3 years ago

I see. so~let me curious to ask, what does it do?

ahdung commented 3 years ago

I think I got it, it can be a message receiver, accept message in, but never process out. right?

cosullivan commented 3 years ago

yes that is correct.

If you wanted to forward the message you would need to handle that yourself.