smtp - PowerShell configure smtpserver -


in powershell how 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 , subbody'     = 'emailto@mail.com'     = 'emailfrom@email.com'     smtpserver = 'smtp.email.com' } send-mailmessage $mailprops -credential $credentials 

no matter if use smtpserver: 'smtp.email.com' or $ipsmtp still same result.

this ps code missing credentials for'smtp.email.com'. has username , password associated enter it.

error code:

send-mailmessage : specified string not in form required e-mail address. @ 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 : email cannot sent because no smtp server specified. must specify smtp server  using either smtpserver parameter or $psemailserver variable. @ 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 


Comments