Hello i am having some problems sending mails thoug my site.
I keep getting the error
The SMTP server requires a secure connection or the client was not authenticated. The server response was: SMTP authentication is required.
My Web.config have
<system.net>
<mailSettings>
<smtp from="XXXX@XXXXX.XX">
<network host="mail.XXXXX.XX" port="25" userName="XXXX@XXXXX.XX" password="XXXXXXXX" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>
And my code
MailMessage message = new MailMessage();
message.From = new MailAddress("XXXX@XXXXX.XX");
message.To.Add(new MailAddress(split[0]));
message.Subject = split[1];
message.Body = ContactUsBody(model);
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Send(message);
It throws the error on client.Send(message), i think that for some reason it dose not use the password and username from the config.
I have tried logging on to the email account though thunderbird and have no problems sending or receiving mails there.
What am i doing wrong here?
It does not use the credentials that you’ve provided because you have set it to use default credentials.
Try this: