In PowerShell how do you configure smtpserver:
ping "stmp.email.com" = xxx.xx.xx.xxx
$smtpServer = xxx.xx.xx.xxx or "stmp.email.com"????????
PS code:
$IPsmtp = 'xxx.xx.xx.xxx'
$PlainPassword = "adminpassword"
$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
$Username = "MYSITE\Administrator"
$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword
$mailprops=@{
Subject = 'This Subject'
Body = 'The Body and the subBody'
To = 'emailto@mail.com'
From = 'emailfrom@email.com'
SmtpServer = 'smtp.email.com'
}
Send-MailMessage $mailprops -Credential $Credentials
No matter if I use for SmtpServer: 'smtp.email.com' or $IPsmtp I still get the same result.
This ps code is missing the credentials for'smtp.email.com'. It has a username and password associated with it but nowhere to enter it.
error code:
Send-MailMessage : The specified string is not in the form required for an e-mail address.
At C:\Users\Administrator\Documents\ps\Email.ps1:14 char:1
+ Send-MailMessage $mailprops -Credential $Credentials
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [Send-MailMessage], FormatException
+ FullyQualifiedErrorId : FormatException,Microsoft.PowerShell.Commands.SendMailMessage
Send-MailMessage : The email cannot be sent because no SMTP server was specified. You must specify an SMTP server by
using either the SmtpServer parameter or the $PSEmailServer variable.
At C:\Users\Administrator\Documents\ps\Email.ps1:14 char:1
+ Send-MailMessage $mailprops -Credential $Credentials
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Send-MailMessage], InvalidOperationException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.SendMailMessage
- Moved by Ethan HuaMicrosoft contingent staff, Moderator Friday, July 17, 2015 7:59 AM powershell related issue