After running below code
Send-MailMessage -to "someone@somedomain.com" -from "DhimantR@somedomain.com" -Subject " Test message" -Body " Test message" -SmtpServer " 10.10.10.10"
If you run into error given below
Send-MailMessage : Unable to connect to the remote server
At line:1 char:17
+ Send-MailMessage <<<< -to someone@somedomain.com -from "DhimantR@someDomain.com" -subject " Troubleshooting" -Body "Some Text or file attachement" -sntpserver "smtpserver"
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.Send MailMessage
Try this solution
Solution: one of the possible problem is your anti-virus software blocking to connect SMTP server using PowerShell
In my case it is McAfee
Steps:
Right click on McAfee icon
Click on Virus Scan Console
Double click on Access Protection on VirusScan Console
On Access Protection tab
Go to Anti-Virus Standard Protection
On right hand side, double click on Prevent mass mailing worms from sending mail
On process to exclude tab, add PowerShell.exe at the end
Click ok
Click apply on Access Protection
Click ok
That's it and try again to send mail using Send-MailMessage
Post your question or comment