omg, I know some people are trying to be helpful here, but please just don't repeat the same stuff (particularly when it doesn't work!)
Anyway, the reason you're seeing these issues is the SSL certificate being issued by the mail server you're connecting to doesn't have a name embedded in it that matching the mail server you've configured in iOS. (Previously you could tell iOS to ignore this and drive on, which is essentially telling iOS to accept what could be a fake or counterfeit certificate, meaning someone could be intercepting or altering your communications between you and the server - hello NSA, unscrupulous ISP's)
When you get the error message, go into the detail screen, near the top will be a name or list of names (including wildcards) the certificate is valid for. The mail server name you configure into iOS must match that, else you'll get the error.
To give an example, because it's relevant here, people using custom domain names from Dreamhost (that don't use a private SSL certificate - you'll know if you have that / i.e. pay for it) will notice the details in the SSL certificate say it's valid for *.mail.dreamhost.com. This means the mail server name you configure in iOS must match this. At this point you probably need to go to your providers site to find out the exact name to use. Dreamhost users should look at the instructions here: https://help.dreamhost.com/hc/en-us/articles/214918038-Email-client-configuratio n-overview. It essentially tells you to go to the control panel and look at the "data centers" area under support. According to their instructions, if it says "homiemail-sub5", the servername ends up being sub5.mail.dreamhost.com. You'll need this for the incoming IMAP server name and the outgoing SMTP server name.
The alternatives are to turn off SSL (i.e. turn off encryption) so your mail, including password, goes over the entire internet in the clear (Not a good idea), or purchase an SSL certificate that has your custom domain name in it. (This is not worth the money or hassle)
Good luck!