Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a

Discussion regarding the Standard version.
Post Reply
flo
Posts: 14
Joined: Tue Nov 18, 2014 2:54 pm

Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a

Post by flo » Sun Aug 08, 2021 5:58 pm

I'm getting error
Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.
I checked here: https://forums.asp.net/t/1483523.aspx?where+do+you+place+the+mail+settings+in+the+web+config+file+ and added to my web.config:

Code: Select all

<system.net>
 <mailSettings>
  <smtp from="info@mydomain.com">
  <network host="localhost" password="" userName=""/>
  </smtp>
 </mailSettings>
</system.net>
but still the same error as above occurs.

When I send via localhost it works fine, but when I send using credentials and a full domain name like so:

Code: Select all

   
	Dim Msg As MailMessage
	Dim mailObj As New SmtpClient
	mailObj.Host = "smtp.mydomain.com"
	Dim basicAuthenticationInfo As New System.Net.NetworkCredential("info@mydomain.com", "mypassword")
	mailObj.UseDefaultCredentials = False
	mailObj.Credentials = basicAuthenticationInfo

	Msg = New MailMessage
	Dim To_Addr As MailAddressCollection = Msg.To
	To_Addr.Add(New MailAddress("john@gmail.com", "john@gmail.com"))
	Msg.From = New MailAddress("info@mydomain.com", "mydomain")
	mailObj.Send(Msg)
	
This is when I get the above error. How can I debug this?

Post Reply