I need to debug Send-MailMessage
command. In linux, I can see the logs of sending mail, via tail -f
. There is an option to see the logs of this command? I want to send mail to an external domain, it runs but without any status.
Powershell send-mailmessage logs
commandpowershellwindows-server-2012-r2
Best Answer
No return code usually means SMTP 2xx or: "the SMTP server accepted it". The CMDlet itself won't generate any output, as you can read here. If you have access to it, you can debug the mailflow on the corresponding mailserver.
If something went wrong,
Send-MailMessage
would output your SMTP server error code in your powershell window, like:5.7.54 SMTP; Unable to relay recipient in non-accepted domain
OR the receiving SMTP server would return a mail with the bounce message to the-From
address, like:550 5.1.10 RESOLVER.ADR.RecipientNotFound; Recipient not found by SMTP address lookup
(not all servers behave like this).