When a script mails an alert and nothing arrives, I’d like to know whether the SMTP side is the problem before I start guessing. msmtp has a mode for that, and it also hands you the certificate fingerprint you need for pinning.
msmtp --serverinfo --tls --tls-certcheck=off --host=smtp.example.com --port=587
This is the form the msmtp manual uses in its configuration example, with the port added. The server information mode prints what it can detect about the server and then exits. Without sending a message, you see the supported SMTP features: the size limit (SIZE), PIPELINING, STARTTLS, AUTH (authentication), DSN and ETRN.
With TLS switched on it also prints details about the server certificate: owner, issuer, activation and expiration time, and the SHA256 fingerprint. That fingerprint is the value for the tls_fingerprint setting in ~/.msmtprc, which pins one specific certificate instead of trusting a list of CAs.
account alerts
host smtp.example.com
port 587
tls on
tls_fingerprint 00:11:22:...
The caveats are real. --tls-certcheck=off switches off the certificate check for this one call, so the fingerprint you read comes from a server you did not verify. Compare it with a value from a trusted place, such as the provider’s own page, before you pin it. The manual also says you have to update the pinned fingerprint whenever the server certificate changes, so a renewed certificate breaks your alert mails until you paste in the new value.
The example follows the msmtp manual. msmtp was not installed here, so the command was not run and no output is shown.
Further reading: msmtp manual