Optimized X-ray generation by electron–ion recombination in the presence of powerful laser fields