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

    Question

  • 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.

     

    Tuesday, January 23, 2007 10:17 PM

Answers

  • 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,

    Thursday, January 25, 2007 9:04 AM

All replies

  • What authentication mechanism does the server you are sending to require?
    Thursday, January 25, 2007 1:08 AM
  • 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)

     

     

    Thursday, January 25, 2007 4:42 AM
  • 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,

    Thursday, January 25, 2007 9:04 AM
  • 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)

     

    Thursday, January 25, 2007 6:35 PM
  • 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!!!

    Friday, January 26, 2007 7:39 AM