"Send-MailMessage : The remote name could not be resolved:" Error shows while using Send-MailMessage cmdlet ?

Svb 71 Reputation points
2022-03-08T04:37:01.27+00:00

Hi !
Send-MailMessage -SmtpServer "abc.contoso.com" -From "******@abc.contoso.com" -To "******@abc.contoso.com" -Subject "Test" -Body "Good Morning"

When I use the above code it show error
"Send-MailMessage : The remote name could not be resolved: abc.consto.com"

Can anyone tell why its not working and show that error?

Thank you!

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,182 questions
Outlook | Windows | Classic Outlook for Windows | For business
Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Exchange | Exchange Server | Management
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} vote

Accepted answer
  1. Kael Yao 37,746 Reputation points Moderator
    2022-03-09T01:31:37.247+00:00

    Hi @Svb

    As mentioned above, please also make sure you have checked these settings in your tenant: Error: Authentication unsuccessful

    The issue may be caused by Azure Security Defaults is enabled (by default) in your tenant, and you need to disable it in Azure AD protocol.

    There is also a link with the same issue for your reference: 535 5.7.139 Authentication unsuccessful


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Ashok M 6,846 Reputation points
    2022-03-08T05:17:27.137+00:00

    Hi,

    If this is for on-premise Exchange, please check if the DNS record is available and resolvable for smtp name ABC.contoso.com. Alternatively, you can also try server fqdn, servername.domain.com

    In this command, it looks like your email address is ABC.contain.com and you are using the same in SMTP server which will resolve to the Domain controller in case your domain is ABC.contoso.com. So try creating a new record like smtp.abc.contoso.com resolving to Exchange and use it in send-mailmessage

    Also check for firewall ports 25/587 is allowed.

    If the above suggestion helps, please click on “Accept Answer” and upvote it.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.