.. in your country. Saying something is illegal without mentioning jurisdiction is meaningless.
> not allowed by ToS
The service being signed up to, perhaps. But it isn't clear to me that it's banned by gmail's tos especially since he's using the service APIs normally.