If you know the login credentials are fine but you still get this error, then you should:

1) go into admin panel -> Miscellaneous -> PHP Info and search for “Registered Stream Socket Transports” and make sure it contains at least “tls, tlsv1.0, tlsv1.1, tlsv1.2”.
As an example, in my current install, i have this: “tcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2”.

2) Make sure your password does not contain special chars like the & sign. If it does, change it so that it doesn’t.

3) If you are using CPanel, go into WHM > Tweak Settings > Allow all users to make external SMTP connections.