locked
Send e-mail stopped working RRS feed

  • Question

  • I have this code in a library I wrote for most of my applications

    sc = new SmtpClient(MailHost, Port);//at initialization
    ...
    mm = new MailMessage(mmFrom, mmTo, mmSubj, mmBody);
    sc.Send(mm);

    My applications run as scheduled tasks on various 64-bit servers in the company and e-mail me reports on what they did or found.

    My development machine was 64-bit hardare with 32-bit OS (Win 7 Enterprise). I have to test my applications end-to-end when I add a new feature or whatever.
    AOK until my development computer started having problems. Dog slow and other company applications and Microsoft applications freezing or crashing.

    I have a new computer now, with 64-bit OS (Win 7 Enterprise). The same applications that still run fine on the servers throw an exception on my new computer when sending the e-mail:
    The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated

    What can I do to fix this? I still need to be able to do end-to-end testst before I deploy a change.
    It is probably some setting I need to make on the new computer (or have a service tech do it)
    The applocations are C#, but please direct me to the correct forum if this is not the one.

    Thanks,

    Jon Jacobs, There are 10 kinds of people: those who understand binary and those who don't

    Monday, April 9, 2018 4:03 PM

All replies

  • You would have to add credentials for sending the email.

    sc.Credentials = new System.Net.NetworkCredential("yourusername", "yourpassword");


    Gaurav Khanna | Microsoft MVP | Microsoft Community Contributor

    Monday, April 9, 2018 4:12 PM
  • Thank you. I did that, and now I get:

    "Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as this sender"

    Keep in mind my new computer is the ONLY computer in the company running my applications where I have this problem.


    Jon Jacobs, There are 10 kinds of people: those who understand binary and those who don't

    Monday, April 9, 2018 6:29 PM
  • If you are in domain account you can use SmtpClient.UseDefaultCredentials = true; (it is not static). Client uses windows credential for current user.
    Monday, April 9, 2018 8:04 PM
  • >If you are in domain account

    I am

    >SmtpClient.UseDefaultCredentials = true; 

    mailer.sc.UseDefaultCredentials = true; 

    Did that. Still the same error.

    Something on  this computer is set to block SMTP mail, I think.

    Could it be an antivirun setting?


    Jon Jacobs, There are 10 kinds of people: those who understand binary and those who don't

    Monday, April 9, 2018 8:49 PM
  • Hello Jon,

    Something need to be clear.

    Is it a custom SMTP Server created by yourself? if so you could see below configuration.

    5.7.1 Client does not have permission' error while sending email from code

    Did you want to send mail that belongs to another domain? it might be impossible to send mail from "@anotherdomain.com" because server will reject this with 5.7.1 error.

    Best Regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Edited by Fei Hu Tuesday, April 10, 2018 3:05 AM
    Tuesday, April 10, 2018 3:04 AM
  • That link was very enlightening. I wonder how I could get that SMTP test tool. I use the company SMTP host. I guess you could call my code a custom client. All the e-mail senders and receivers are in the same domain, the company domain. 

    That Active Directory Service Interfaces (ADSI) might be what is needed, but I have no idea how to get to those screens.


    Jon Jacobs, There are 10 kinds of people: those who understand binary and those who don't

    Wednesday, April 11, 2018 12:38 PM
  • Hello Jon,

    >>The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated

    It's so strange behavior that only computer throws the exception. The most possible is the computer isn't a member of your domain. Please ensure you are not in this case.

    Best Regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 18, 2018 8:28 AM