SMTP Authentication problem

  • Thread starter Thread starter eruth
  • Start date Start date
E

eruth

Hi all,

I'm trying to send an e-mail from a vb.net web form. I can create the
message, but when it comes to actually sending it I get the following
error. "Mailbox name not allowed. The server response was: Server
policy dictates you must authenticate first "

So far as I can tell, my code is doing what it's meant to, but I'd
appreciate someone casting an eye over it to make sure. This is based
on a couple of examples found through google.
<code>
Dim Message As MailMessage = New MailMessage()
Dim Smtp As New SmtpClient()
Dim SmtpUser As New System.Net.NetworkCredential()
'-- Build Message
Message.From = New MailAddress("(e-mail address removed)", "Me")
Message.To.Add(New MailAddress("(e-mail address removed)", "you"))
Message.IsBodyHtml = False
Message.Subject = "test"
Message.Body = "This is a test"
'-- Define Authenticated User
SmtpUser.UserName = "user"
SmtpUser.Password = "password"
SmtpUser.Domain = "mydomain.co.uk"
'-- Send Message
Smtp.UseDefaultCredentials = False
Smtp.Credentials = SmtpUser
Smtp.Host = "mydomain.co.uk"
Smtp.Port = 25
Smtp.DeliveryMethod = SmtpDeliveryMethod.Network
Smtp.Send(Message)
</code>
 
The error message suggests that mydomain.co.uk is asking for SMTP
authentication.

Are you sure that particular SMTP can relay email messages without
authentication.
 
If authentication is turned off, the mail can be sent, but as soon as
we turn it back on, I get that message.
 
Check if your authentication requires some security encryption.

Turns out all this was caused not by my code, but by the SMTP server
not being configured correctly. Nice to know it wasn't me though ;)
 
Back
Top