The smtp server requires authentication, but I believe that it already has it

I get a message that the server requires authentication when I get the bottom line of the following code.

MailMessage message = new MailMessage(); message.From = new MailAddress(" me@myemail.co.uk "); message.To.Add(new MailAddress(" me@myToAddress.co.uk ")); message.Subject = "Message subject"; message.Body = "This is the content"; SmtpClient client = new SmtpClient(); client.Send(message); 

However, I thought I already gave him the information he requires in webconfig, as follows:

 <mailSettings> <smtp from=" me@myemail.co.uk "> <network host="mySMTPserver" port="25" userName="myEmail" password="myPass" /> </smtp> </mailSettings> 

Any advice that I really liked, I read a lot of posts here, and they all all seem to provide login in the same way.

+4
source share
1 answer

Two attempts:

SET client.UseDefaultCredentials = false

SET Port:

  client.Port = 587 

These properties can also be set in the .config file.

To understand why 587 see http://mostlygeek.com/tech/smtp-on-port-587/

+1
source

Source: https://habr.com/ru/post/1446832/


All Articles