Here is my powershell to send an email from my smtp server.
My real smtp server exists and functions correctly.
This PS script takes a long time to run and below is the error code:
$subject = "This Subject" $body = "The Body and the subBody" $emailTo = "toemail@email.com" $emailFrom ="fromemail@email.com" $smtpServer = smtp.email.com $port="25" $smtp = new-object Net.Mail.SmtpClient($smtpServer) $credentials=new-object system.net.networkcredential(email@email.com,password) $smtp.credentials=$credentials.getcredential($smtpserver,$port) $PlainPassword = "mainpassword" $SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force $UserName = "MYSITE\Administrator" $Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword Send-MailMessage -To $emailTo -Subject $subject -Body $body -SmtpServer $smtpServer -From $emailFrom -Credential $Credentials -Port $port -UseSsl
PS Error Code:
InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
- Edited by Philosophiae Monday, July 13, 2015 11:42 PM