Unable to catch SMTP errors while sending mail using Send-MailMessage RRS feed

  • Question

  • I have got a list of report in which few users are not in the organization, in such cases when the script tries to send email to those invalid addresses i should be able to catch errors, which is not happening. Can someone help to fix this?

    Wednesday, May 15, 2019 11:42 AM

All replies

  •  i should be able to catch errors, which is not happening. 

    What error are you getting? Do you have a try/catch coded? Is the email address in an invalid format or is it just a address that no longer exists?

    If I send an email to a bad address like, the SMTP server won't know that it's invalid until it contacts and gets an error status. From a client perspective, the email has been sent. The "error" is the reply email from the destination that the address you used is invalid.  

    If you are using Exchange, then you might have better luck asking this question in an Exchange forum.
    • Edited by MotoX80 Wednesday, May 15, 2019 12:39 PM
    Wednesday, May 15, 2019 12:37 PM
  • Yeah i got your point as it needs to validate the error with Domain name. I am using anonymous name to send my email from script has to fetch email id's in the csv file and send email, if it finds an email addresses which might be not valid or user might left such cases i want that email failure to be detected and wanted it to notify for my common DL. Is there any other option to detect failure? using -DeliveryNotificationOption?
    • Edited by Naveenrj Wednesday, May 15, 2019 12:50 PM
    Wednesday, May 15, 2019 12:50 PM

    "The -DeliveryNotificationOption parameter specifies two values, OnSuccess and OnFailure. The sender will receive email notifications to confirm the success or failure of the message delivery."

    Looks like the "error" will be an email that is sent to the inbox of the "from address". You will have to read through and parse those to determine the invalid addresses.  

    Wednesday, May 15, 2019 1:13 PM
  • "Delivery Notification" isn't the same as "Read Receipt".

    "DeliveryNotification" is a request to the final destination SMTP server, but not all (and perhaps not many) servers honor the request. The probability of getting a delivery notification decreases as the number intermediate "hops" increases as it only takes one server in the chain to ignore the request and not pass on the request to the next server. There are also a surprising number of servers that simply don't support ESMTP.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Wednesday, May 15, 2019 2:49 PM
  • Delivery notifications are emails.  Send-MailMessage does not know about emails received because it is not associated with a mailbox.  You would need to use a POP3 provider to receive these emails.

    The rejections can be extracted from an associated Outlook mail session.


    Wednesday, May 15, 2019 4:56 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,


    Just do it.

    Monday, May 20, 2019 6:49 AM
  •  This issue is not yet resolved, i am now working with my Sys Admin team members for having Exchange connectivity access enabled for verifying the email address filtered through scripts. If that works i will post the solution here.

    • Edited by Naveenrj Tuesday, June 4, 2019 5:30 AM
    Friday, May 31, 2019 9:19 AM
  • I will wait for your good news.

    Just do it.

    Friday, May 31, 2019 9:32 AM
  • I got this below command to verify email valid id's by connecting to Exchange\0365.

    Get-Recipient -Identity

    But when i checked for the permission the account which i am running does it needs any specific permission to connect to Exchange\O365 and wt about AD permission required for it. Can some one help with privileges to execute above command.

    Tuesday, June 4, 2019 5:34 AM
  • You need to post in the O385 forums for help with configuring O365 for access from SMTP or access through the PS remoting.  They will help you with the configuration changes.


    Tuesday, June 4, 2019 6:12 AM
  • Thanks Jrv
    Tuesday, June 4, 2019 8:37 AM