# Get smtp.office365.com certificate output
echo | openssl s_client -showcerts -servername smtp.office365.com -connect smtp.office365.com:995 2>/dev/null | openssl x509 -inform pem -noout -text
openssl s_client -showcerts -connect smtp.office365.com:587 -starttls smtp 2</dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
# Export smtp.office365.com certificate to .pem
openssl s_client -servername smtp.office365.com -connect smtp.office365.com:995 </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /sslDir/smtp.office365.com.pem