I want to send an email with a powershell script to mailcow.

the script below works in 587 but not in 465 ?

$from = "myname@mydomaine.com"
$to = "info@domaine.com"
$smtp = "mail.mydomaine.com"
$sub = "test"
$body = "test mail"
$secpasswd = ConvertTo-SecureString "mypassword" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential($from, $secpasswd)
Send-MailMessage -To $to -From $from -Subject $sub -Body $body -Credential $mycreds -SmtpServer $smtp -Port 587 -UseSsl -BodyAsHtml

On the same machine Thunderbird sends emails on port 465, and it works.

Do you have any idea of ​​the problem, on mailcow I can’t find an error in the logs, or I’m not looking in the right place

Thanks for your advices

Probably Send-Mailmessge is using STARTTLS after it connected an unsecured connection.
But with port 465 you MUST start a TLS connection rightaway (which Send-Mailmessage seems not to support)

Have something to say?

Join the community by quickly registering to participate in this discussion. We'd like to see you joining our great moo-community!

No one is typing