Sorry to hear this, Phil.
As it's working on iPad/iPhone, you know that the issue is with your tinkering on the Mac, not your email provider.
Is it your btinternet email, that's playing up?
You might want to wait to hear from others in case there's a simpler fix, otherwise I'd be inclined to:
Open Mail on your iMac
Mail (top left of menu bar) > Preferences
Click Accounts
Click the + symbol (bottom left of window)
Select 'Other Mail Account...' and click Continue
Enter the details but for 'Name' just make sure you differentiate it from your current email account details (eg. If your account is named Phil Ward, call this new one Phil T Ward, for example).
The default settings it selects are then very likely what should get you back up and running again with IMAP, removing any problematic tinkering.
Try sending and receiving an email. If all works, you're all set.
You could either then compare the Settings of the two accounts and make the original match the new, or simply delete your original account and use the new.
Hope that helps, or as I say, see if someone else can suggest a simpler 'try this'
Cheerio
Adam