locked
This mail server requires authentication !!!

    Kérdés

  • I have this code to send email

    MailMessage Mail = new MailMessage();
    Mail.From =
    new MailAddress("ss@ss.com");
    Mail.To.Add("aa@aa.com"
    );
    Mail.Subject =
    this.txtMessageTitle.Text.Trim();
    Mail.Body =
    this.txtMessageBody.Text.Trim();
    SmtpClient smtpclient = new SmtpClient("mail.ServerName.com");
    smtpclient.Credentials =
    new NetworkCredential("ss@ss.com":, "xxxxxxxx");
    smtpclient.Send(Mail);

    But I get Error Message when I try to send the Email

    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.

    Note : I need to do some thing like in the second picture by code
    https://help.3essentials.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=85

     

    and thanks with my best regarding
    Fraas

    2006. április 11. 10:03

Az összes válasz

  • can any one help me please :(
    2006. április 19. 23:06
  • try changing your code from: smtpclient.Credentials = new NetworkCredential("ss@ss.com":, "xxxxxxxx");
    to: smtpclient.Credentials = new NetworkCredential(<username>, "xxxxxxxx");
    or: smtpclient.Credentials = new NetworkCredential(<username>:, "xxxxxxxx", <domain>);
    In other words, get rid of the format "user@domain.com" for the username in the network credential.

    2006. április 19. 23:38
  •  

    I have the same problem, but I didn't get what JonCole meant. What is the difference between ss@ss.com and <username>? Isn't ss@ss.com supposed to be the username?

     

    2007. szeptember 2. 12:52
  • Hi

     

    try this, it worked for me!

     

    Dim Smtp As New SmtpClient()

    Dim SmtpUser As New System.Net.NetworkCredential("abc@cool.com", "xxxxx")

    'setting smtpuser to smtpclient

    Smtp.Host = "smtp.cool.com"

    Smtp.DeliveryMethod = SmtpDeliveryMethod.Network

    Smtp.UseDefaultCredentials = False

    Smtp.Credentials = SmtpUser

    'Smtp.Port = 25

    Smtp.Send(mail)

     

    Regards

    Nimbus2000

    • Válasznak javasolta: Calamitatum 2009. július 2. 0:51
    2007. november 6. 21:20
  • Hola Nimbus2000 , muchas gracias  por este codigo, tenia el mismo problema y gracias a ti lo he solucionado
    2008. február 19. 20:53
  • Dear Nimbus,

     

    i am using your code...but I am also got the same error..please help me to resolve that problem.

     

    2008. március 10. 5:23
  • Dear Frass,

     

                    r u got the solution?....please help me..i also got the same error...

     

    2008. március 10. 5:25
  • HI Thiagu,

     

    What is the error message you are getting? I will try to resolve your issue.

     

    Regards,

    Nimbus.

     

    2008. március 12. 0:56
  •  

    Hi,

     

    I have the same problem. It's strange, because my code was working well, but it showed an error after I changed some other codes in Page_Load.

     

    The message is:

     Server Error in '/' Application.


    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.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Net.Mail.SmtpException: 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.

    Source Error:

    Line 186:                Dim smessage As New SmtpClient("mail.domain.com")
    Line 187:                smessage.Credentials = New Net.NetworkCredential(email@domain.com, "pass")
    Line 188:                smessage.Send(message)
    Line 189:                message.Dispose()

     

    and my code is:

     

    Dim message As New MailMessage

    message.To.Add(txtemail.Text)

    message.From = New MailAddress("email@domain.com")

    message.Subject = "Subject"

    message.IsBodyHtml = True

    message.Body = "Body"

    Dim smessage As New SmtpClient("mail.domain.com")

    smessage.Credentials = New Net.NetworkCredential("email@domain.com", "password")

    smessage.Send(message)

    message.Dispose()

    2008. május 12. 8:41
  • I had the same issue here and we discovered that our SMTP server settings were set to denay realy from any incoming IP addresses except for a few exceptions add manually.
    So, I added the local network dev workstation ip range (ex: 172.34.12.*) to the denied exclusion list and it worked like a charm!
    Hope this help,

    Stef
    "At the end of the day, it's what you do, not what you say." - Neal Morse, musical genius
    2009. június 17. 18:04
  • It works for me. In some cases is important include domain in NetworkCredential.
    2009. július 2. 0:52
  • I'm sending an e-mail from windows service using the System.Net namespace.

    I got this error while sending the e-mail without providing credentials. As soon as I got the error, I figured out that the authentication is missing.

    This solution works fine for me.

    Thanks Nimbus.

    Regards,
    Sricharan.S


    2009. augusztus 1. 11:19