Ok, I just did this. If you want second, rather than third class, it runs to Nampula Wed, Fri, Sun and it runs to Cuamba Tu, Th, Sat. Third class runs every day except Monday.
The people at the ticket counter recommend buying second-class tickets the day before. So don't worry about that. For third class, you can do it whenever. Second class when I was on it was full, but wasn't full at Cuamba, so you'd probably be safe waiting til morning too--but there are often long lines.
Rudi: were you the one coming from Malawi on the Liwonde-Nayuchi/Entre Lagos train? Just so you know, if you want to do that route, you have to secure your visa in advance. I didn't, so I had to go to Chiponde/Mandimba the next day, so I can't give you any more info on that.