I get a message saying the server requires authentication when i get to the bottom line of the following code block.
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 had already given it the info it 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 much appreciated, I read many posts on here and they all seem to be providing the login in the same way.
Two things to try:
SET
client.UseDefaultCredentials = false
SET port:
These properties can also be set in the .config file
To understand why 587, see
http://mostlygeek.com/tech/smtp-on-port-587/