Hello guys!
I'm trying to send an e-mail from PowerShell (Windows 2008 R2) and I keep getting this error:
Exception calling "Send" with "4" argument(s): "Failure sending mail."
At C:\path\script.ps1:14 char:12
+ $smtp.Send <<<< ($emailFrom, $emailTo, $subject, $body)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
If I try the cmdlet:
Send-MailMessage -to user1@domain.com -from user2@domain.com -body "test" -Subject "test" -SmtpServer SMTP.domain.com
I get this error:
Send-MailMessage: Unable to read data from the transport connection: net_io_connectionclosed. At line:1 char:17
+ Send-MailMessage <<<< -to user1@domain.com -from user2@domain.com -body "test" -Subject "test" -SmtpServer SMTP.domain.com
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtepException
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
Any ideas?
Thanks,
Yuri