I am new in powershell, i was trying to send a mail through powershell scripting and i am able to send only for gmail, ymail etc but not for private sector companies mail where i work like comanies mail domain is email@example.com.
I have SMTP server for those mails but it thows an error again and again
Exception calling “Send” with “4” argument(s): “Failure sending mail.”
At line:9 char:17
- $SMTPClient.Send <<<< ($EmailFrom, $EmailTo, $Subject, $Body)
- CategoryInfo : NotSpecified: ( , MethodInvocationException
- FullyQualifiedErrorId : DotNetMethodException
I was tried lots of methods but it not works.
the powershell worsion on my system(os: win 7) is 1.0
Also i tried to execute this script from server end(win server 2008 r2 and 2012)
$EmailFrom = "firstname.lastname@example.org"
$EmailTo = "email@example.com"
$Subject = "Notification from XYZ"
$Body = "this is a notification from XYZ Notifications…"
$SMTPServer = "smtp.ge.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("firstname.lastname@example.org", "************");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)