Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SmtpClient is working with wrong credentials

My Smtpclient is working with following setup

SmtpClient client = new SmtpClient();
client.Host = server;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("username", "totallywrongpassword", "DOMAIN");

try
{
    client.Send(message);
}
 catch
 {
   // no exception is thrown, emails are send
 }

I am providing invalid credentials, yet the emails are being sent.

What am I configuring wrong?

The smtp server and client are on the same local domain.

like image 770
Mathias Colpaert Avatar asked Sep 05 '25 03:09

Mathias Colpaert


1 Answers

Most likely is that your SMTP server is set up to allow local networks to send off it without needing credentials. Your code is totally correct and if the server is still letting you send off, I'd contact the administrator first.

like image 154
Josh Avatar answered Sep 07 '25 20:09

Josh