• Hello and welcome to our new forums. We upgraded our forum sites to a more robust and modern system which we hope you will enjoy. Be sure to check out your profile by clicking the button on the top right and configure your preferences, signature, time zone, avatar, etc. as you wish. If you need help with using this new forum'ware try the help link on the bottom right.

    Click here to review your account now.

Question Custom Windows service - Send emails via SMTP

demondan

Member
Joined
May 24, 2018
Messages
15
Programming Experience
1-3
Hi
I have developed a windows service that receives requests to send out emails via a SQL database. Other applications populate the database and the windows service checks the database and processes the information to send out an email. I am struggling with understanding how specifying credentials works. I want it to use a specific domain username/password and I thought it was working but I noticed it sends out emails regardless of what I set as the username and password. I have the following code in regards to the credentials:

smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("test", "fail");

So in this case where username is test and password is fail - I would have thought this should not work. However it works! Why is it not failing?

Thanks!
Dan
 

demondan

Member
Joined
May 24, 2018
Messages
15
Programming Experience
1-3
Ha, that's a good question. I will have to speak with the server admin and find out! Cant believe I didn't think to consider that - thank you!
 

demondan

Member
Joined
May 24, 2018
Messages
15
Programming Experience
1-3
Hi
Sorry, bank holiday weekend so I haven't been to work. I have just posed the question to the server admin. Interestingly if I put the correct username and password in, it fails. But if I put the correct username in and a password which should fail, it works. I just don't understand the logic which the code goes through? Why does it fail with the correct username/password but I put in credentials that don't exist and it works? Regardless of if we have required credentials enabled I don't understand the process the code goes through?
thanks
Dan
 
Top Bottom