How to resolve this fatal error '2006 MYSQL server has gone away'?
A few minutes to send 40 emails indicates that this cron job is computationally expensive. You are probably hitting against MySQL's wait_timeout limit.

I wouldn't necessarily suggest changing your MySQL configuration. Drupal's cron runs aren't meant to take more than a few minutes at a time. Instead, this may be better suited to a cron queue.

In a cron queue, each individual email to send would be a job in this particular queue. During each cron run, as many of those jobs in each queue are processed until some set time limit has passed, and the remaining jobs are deferred for the next cron run.