Exponential sums involving the divisor function over arithmetic progressions