Sending email from a server

by Jul 13, 2011

I have his code to email a report that is gernerated on a weelky basis:

$Date= Get-Date

$EmailFrom = ""
$EmailTo =
$Subject = “Report”
$Body = “Created on $Date”
$File = “C:temptest.txt”      

$Msg = New-Object System.Net.Mail.MailMessage $EmailFrom, $EmailTo , $Subject, $Body
$Attachment =  New-Object System.Net.Mail.Attachment $File

$SMTPServer = “email_hosted_SMTP_server”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)         
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = $Ecreds     


In testing it worked great on my Win7 Pro box but from the server it get the following message in powershell

"exception calling "Send" with "1" argument the remote certificate is invalid according to the validation process"

what did I do wrong?