This always a pain in the neck 'cos joined up government is a myth.
HMCE, God Bless them need to be told for all flights outside the UK Immigration need to be told for all flights outside Great Britain and Special Branch need to be told if you're inbound or outbound to/from the Common Travel Area.
The notice periods vary, customs 4 hours EU and Common Travel, 24 outside EU. Immigration I've always assumed is the same as Customs but I now realise I couldn't swear to that
Special Branch 12 hours to the CI, but 24 hours everywhere else.
I await correction of the foregoing!
HMCE allow email to a central site, bless them. All the others require fax to local offices, except when they allow email, somewhat reluctantly.
I take my hat off to the operations people at the fields I use where they handle all this, I really struggle when I'm on my own with no easy access to a fax machine.