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

  • Question

  • Hello,

    I am logged in with my windows domain account.

    I am writing a DOS Console app , trying to send a email from myself to myself.

    Since  UseDefaultCredentials = true , why do I get a error ? 

            

                    MailMessage message = new MailMessage("me@x.y", "me@x.y");
                    message.Subject = "test with UseDefaultCredentials";
                    message.Body = "This is the message body";
                    using (SmtpClient client = new SmtpClient())
                    {                    
                        client.DeliveryMethod = SmtpDeliveryMethod.Network;
                        client.Host = smtpHost;
    
                        client.UseDefaultCredentials = true;
                        client.Send(message);
                    }

    Tuesday, November 17, 2015 10:51 PM

Answers

All replies

  • Wednesday, November 18, 2015 1:26 AM
    Answerer
  • Hi peter,

    You could use below code to check whether the your account is right.

    client.UseDefaultCredentials = true;
    Console.WriteLine((client.Credentials as NetworkCredential).UserName);
    Console.WriteLine((client.Credentials as NetworkCredential).Password);
    //client.Send(message);

    Best Regards,
    Jerry

    Wednesday, November 18, 2015 2:24 AM
  • FYI, when using default Credentials, there will not be password available.

    The SMTP server is going to talk directly with AD to see if the sender's identity is valid.

    Unable to send email out in this case is most likely due to configuration issue, say if the user is not granted right to send email using that address.

    If that email address is not allocated to someone, ask your domain admin/exchange admin to use "Active Directory Users and Computers" MMC snap-in to add the email address to your account. If the email address is assigned to some user already, ask the domain admin/exchange admin to add "send" or "send on behalf of" permission to your account.

    If the .Host points to some computer with IIS5.X/6 SMTP server installed and it's configured to relay mail using your current credential, it should be okay too, with increased probability to be classified as junk mail by mail servers. (Under reason that mail originates from servers without matching MX records)

    Wednesday, November 18, 2015 2:47 AM
    Answerer
  • So i am logged in with my nt account, and  trying to send a email from my nt account exchange mailbox.

    so i should have permission to my own mailbox.

    One thing - i noticed that my mailbox is hosted in outlook.office365.com ---do I need to use different authentication ?

    • Edited by peter clift Wednesday, November 18, 2015 11:30 PM ab
    Wednesday, November 18, 2015 5:59 PM
  • I don't have Office365 account, but if it works like Outlook.com, you should be able to find detailed instruction on connecting application which supports POP3 and SMTP to it.

    Just check and follow everything for SMTP part and your application should work.

    EDIT: Found it. The host name should be smtp.office365.com . You should connect to port 587 with SSL enabled. Note that their SMTP server have set limit so that you could only send mail to 10,000 recipients per day. 30 messages per minute.

    And btw, if you're using Office 365 maybe you can't use default credential, and should be required to pass NetworkCredential object with username and password in order to send email.

    Thursday, November 19, 2015 1:26 AM
    Answerer
  • So the solution was to switch to Exchange Web Service (EWS).

    SmtpClient API does not work (for me).

    Regards, Peter

    Monday, November 23, 2015 9:46 PM