Check SMTP server working or not with powershell {send-mailmessage}
You can do a simple try catch:
try{ Send-MailMessage -from mymailbox@my1stdomain.com -to Recipient@my1stdomain.com -Subject "Test OK" -Body "Test is OK" -SmtpServer mail.my1stdomain.com }catch{ Send-MailMessage -from mymailbox@my2nddomain.com -to Recipient@my2nddomain.com -Subject "Test OK" -Body "Test is OK" -SmtpServer mail.my2nddomain.com }
If the code block in try generates error it will run the catch block.