Mail and webmail SSL cert invalid

I have generated the cert by navigating to Mail > Domain > Checked SSL and letsencrypt

Despite that when I try to use nodemailer it outputs this error:
Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate’s altnames: Host: webmail.example.com. is not in the cert’s altnames: DNS:example.com, DNS:www.example.com

And to confirm if I have read on other posts, yes I have and no solution would do it in my case.

You should use mail.example.com instead of webmail.example.com

Anyway, show the output of (replace example.com by your domain):

echo | openssl s_client -connect webmail.example.com:465 -servername webmail.example.com 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName | tr -d ' '
echo | openssl s_client -connect mail.example.com:465 -servername mail.example.com 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName | tr -d ' '

Try using hostname.domain.com instead …

subject=CN=example.com
X509v3SubjectAlternativeName:
DNS:example.com,DNS:www.example.com

subject=CN=mail.example.com
X509v3SubjectAlternativeName:
DNS:mail.example.com,DNS:webmail.example.com

Ok, then, as I said, use mail.example.com

Still the same error despite changing from webmail to mail. Here is another part of the error i get a bit further down.

reason: “Host: mail.example.com. is not in the cert’s altnames: DNS:example.com, DNS:www.example.com”,
host: ‘mail.example.com’,

Then nodemailer is not using SNI, use example.com or www.example.com or as @eris said, use the hostname of your server.

You are indeed onto something here, but now I am facing that the auth is incorrect:

code: ‘EAUTH’,
response: ‘535 Incorrect authentication data’,
responseCode: 535,
command: ‘AUTH PLAIN’

Despite I know I am using a valid email which would be [email protected] and I am trying to use the same password that I would use for logging in to Roundcube.

Which port are you using?

That would be port 587.

And nodemailer is using starttls? If you want to use a direct TLS connection, use port 465

That got it further, but now it is complaining about not receiving a greeting.

Error: Greeting never received
code: ‘ETIMEDOUT’,
command: ‘CONN’

Maybe you should ask in nodemailer community.