$username = 'peterTheWolf' $password = 'littleRedCap' $secStr = convertTo-secureString -string $password -asPlainText -force $cred = new-object System.Management.Automation.PSCredential $username, $secStr send-mailMessage ` -from 'me@here.xyz' ` -to 'you@there.abc' ` -subject 'The zip' ` -smtpServer 'smtp.some.where' ` -useSSL ` -port 587 ` -credential $cred ` -attachments foo-bar-baz.zip ` -body @' Hello here's the zip file '@
The Send-MailMessage cmdlet is obsolete. This cmdlet does not guarantee secure connections to Perl module Net::SMTP servers. While there is no immediate replacement available in PowerShell, we recommend you do not use Send-MailMessage. For more information, see Platform Compatibility note DE0005.
send-mailMessage
cannot connect to the given SMTP server or indicated port, the cmdLet does not give a meaningful error message. It just says the operation has timed out. $psEmailServer
can be set to the SMTP server. This value is used if the parameter -smtpServer
is not specified.