ASP.net C#, sending email error-the client was not authenticated.

Hi, everyone:

Hope I can get some help here. I've been working on this problem for two days and checked all the resources, but no luck.

I'm a beginner of ASP.net C#. and recently working on an application try to send out emails. Below is my code and error message I got: (I used system.net .mail)

/////////
code in web.config
<add key="MailServer" value="68.142.198.11"/>

<add key="EnableErrorLogEmail" value="false"/>

<add key="ErrorLogEmail" value="XXX@sbcglobal.com"/>

<add key="ProductsPerPage" value="6"

//////code in utilities.cs

public
static void SendMail(string from, string to, string subject, string body)

{

//Create mail message

MailMessage mailMessage = new MailMessage(from, to, subject, body);

//Configure mail client

SmtpClient mailClient = new SmtpClient(ArtHouseConfiguration.MailServer);

//Send mail

NetworkCredential oCredential = new NetworkCredential("XXXX", "XXX");

mailClient.Host = "68.142.198.11";

mailClient.UseDefaultCredentials = false;

mailClient.Credentials = oCredential;

mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;

mailClient.Send(mailMessage);
}

///ERROR I Got

The SMTP server requires a secure connection or the client was not authenticated. The server response was: authentication required

can any expert tell me what's the problem thanks a lot.



Answer this question

ASP.net C#, sending email error-the client was not authenticated.

  • aidimorini

    What authentication mechanism does the server you are sending to require

  • George Clingerman

    Hi, Mark:

    Thanks for replying.

    It's smtp.sbcglobal.yahoo.com. Port 25.It requires authentication but doesnt require SSL (my application doesnt have SSL involved).

    And since I use router, I was wondering if the dynamic IP will affect the authentication. (I called SBCYahoo today, he said it will not)


  • stswordman

    Hi, there:

    Thank you for all your help, I finally got it, the username has to be the full email address instead of only the ID part, besides, the port number needs to be 587.

    Thanks again!!!


  • domukajoor

    Hi,

    Try this,

    1. Use port 587 - give it a try (somewhere i seen that it works with this port fine) - this happens in gmail smtp too... i hope it will solve your problem,
    Refer:
    http://help.yahoo.com/help/us/bizmail/pop/pop-27.html - this link says
    SMTP Port
    If you have adjusted your SMTP server, and you're still experiencing a problem, you may need to use an alternate port. In an attempt to control spam, some Internet service providers now block port 25, which means you may need to use port 587 when sending email via Yahoo!'s SMTP server. Learn how to change ports.


    2. smtp.sbcglobal.yahoo.com - use this string as server instead of giving IP
    http://answers.yahoo.com/question/index qid=1005122001806 (this shows that telnet to this url shows some IP other than yours)

    Please inform me the results,

    HTH,



  • Quilnux

    Hi, Indian Ocean:

    I tried to change the port number, it still doesnt work. So I tried to change the SMTP server as localhost by typping my own IP address in the server value, it gives me the error message

    "No connection could be made because the target machine actively refused it "

    I dont know what's the problem. any suggestions

    thanks

    (PS: if I install my own mail server, will this help also I dont have SSL invovled in my application)


  • ASP.net C#, sending email error-the client was not authenticated.