Send-MailMessage -to “[email protected]” -from “[email protected]” -Subject “Subject Info” -Body “Content” -SmtpServer “Server Name”
Was not able to send mail from a Windows 2008 server and the error message displayed is as listed below:
Send-MailMessage : Unable to connect to the remote server
At line:1 char:17
+ Send-MailMessage <<<< -to [email protected] -from “[email protected]” -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
Found that the the block was in McAfee, when Powershell was excluded from McAfee. Send mail was success.
Steps to exclude Powershell in McAfee is listed below:
- 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.
Thanks,
WintelAdmin