Forum Discussion

__AlexXx__'s avatar
__AlexXx__
Brass Contributor
Jul 26, 2024
Solved

Send-MailMessage : Mailbox unavailable. The server response was: 5.7.60 SMTP

Hi all,

 

This forum really is my last option, cause I checked in the internet for a solution and was not able to find.

I have a hybrid exchange scenario - Exchange2019 + O365 - all the mailboxes are remote mailboxes (hosted in Office365) and we use Exchange2019 only to manage the features and SMTP Relay.

 

The point is that I am trying to send email from an specific mailbox using smtp relay and I am facing the issue below:

 

 

Send-MailMessage : Mailbox unavailable. The server response was: 5.7.60 SMTP; Client does not have permissions to send as this sender

 

The .ps1 script that I'm using is below:

 

 

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

       $sendMailParams = @{
            From = "donotreply @ mydomain.com"
            To = "myname @ mydomain.com"
            Subject = "Test mail from $env:Computername"
            Body = "<p> *email sent for tests purposes* </p>"
            SMTPServer = "smtp.mydomain.com"
            Port = 587
            Encoding = "UTF8"
        }

        Send-MailMessage @sendMailParams -BodyAsHtml -Credential $credential -UseSsl

 

 

 

After running the script, obviously I need to insert the credential then get the mentioned error.

 

Other details regarding my tests:

  • User inserted into '-Credential $credential' part is something like "test@ mydomain.com"
  • The receive conector is allowing the IP source
  • The receive connector is configured to listen port 587
  • The receive connector is configured for SSL, Authentication and Exchange Users as well
  • The relay must be done using SSL and Authentication (I can not use Anonymous)

 

The user test@ mydomain.com is already added as SEND AS into donotreply@ mydomain.commailto:email address removed for privacy reasons

 

Any ideia what I should do to allow the test@ mydomain.com to send emails as donotreply@ mydomain.com using smtp relay?

 

Thanks in advance.

 

  • alavd 

     

    Hi alavd, sorry for delay in responde.
    I could fix the issue using the command Add-ADPermission, as I have an hybrid environment.
    Something like:

     

    Add-ADPermission -Identity "Terry Adams" -User AaronPainter -AccessRights ExtendedRight -ExtendedRights "Send As"

     

    This example grants Send As permissions for Aaron Painter to Terry Adams's mailbox.

     

    Source: https://learn.microsoft.com/en-us/powershell/module/exchange/add-adpermission?view=exchange-ps

3 Replies

  • alavd's avatar
    alavd
    Copper Contributor
    I have the same issue. But with HVE environment and HVE account.
    Does it work if you use "test@ mydomain.com" in From field?
    • __AlexXx__'s avatar
      __AlexXx__
      Brass Contributor

      alavd 

       

      Hi alavd, sorry for delay in responde.
      I could fix the issue using the command Add-ADPermission, as I have an hybrid environment.
      Something like:

       

      Add-ADPermission -Identity "Terry Adams" -User AaronPainter -AccessRights ExtendedRight -ExtendedRights "Send As"

       

      This example grants Send As permissions for Aaron Painter to Terry Adams's mailbox.

       

      Source: https://learn.microsoft.com/en-us/powershell/module/exchange/add-adpermission?view=exchange-ps

Resources