Transistor or not

I’m trying to test an electromagnetic counter (12V, 23mA) with an Arduino MEGA 2560. According to Arduino specs current should be less than 40 mA on the I/O pins. Do you think I can connect the counter directly to Arduino or I will have to use an intermediate transistor?
I know, 23 mA is less than maximum allowed (40 mA) but I will have to run the tests continuous for several hours. Any risk for Arduino overheating?

I'd be inclined to use either transistor or mosfet.

Don't forget freewheeling diode on the coil.

While the Arduino could supply the current it cannot supply the voltage so you will need a transistor, a resistor for the base and 12V supply.

Use a logic an N-channel MOSFET that connects the load to ground. Then You don't even need the base resistor.
An inductive load must have a freewheeling diode regardless of the kind of transistor.

What is the minimum pulse width needed for that counter? Please post your program.
Put counter coil in place of M1, don't forget kickback diode, D1.