Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

powershell script using Net.Mail.SmtpClient not working for my email vendors server

$
0
0

I can use some other tools to send emails (like http://glob.com.au/sendmail/ for example), but for some reason I can't send emails with Net.Mail.SmtpClient.

I am using the same settings as I have configured in my email client (outlook) as well. The vendors server (which I have no access to) uses a different outgoing port (465) and SSL. Currently just trying to send emails to myself.

$CredUser = "me@mydom.com"
$CredPassword = "mypass!"

$EmailFrom = $CredUser
$EmailTo = $CredUser 
$Subject = "Test mail Subject"
$Body = "Test Email Body" 
$SMTPServer = "www.myemailvendor.biz"

$msg = new-object Net.Mail.MailMessage
$msg.From = $EmailFrom
$msg.to.Add($EmailTo)
$msg.Subject = $Subject

$msg.Body = $Body

$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 465) 
$SMTPClient.EnableSsl = $true 
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($CredUser, $CredPassword) 

$SMTPClient.Send($msg)

The error I get is: Exception calling "Send" with "1" argument(s): "The operation has timed out."

How can I troubleshoot this further



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>