Pompeii & Sorrento are not on the mainline network, so buy a ticket to Naples Centrale then buy a ticket locally for the Circumvesuviana Railway,
Alternatively, you can buy tickets direct from Trenitalia, but see the advice here.
If they never come, then you’ve earned the free trip.
tickets in Italy are more flexible, therefore ensure that you validate it in a machine on the platform before boarding.
On the next page you’ll see your departure options by time and price.
For this reason, it’s advisable to buy a return ticket when you are leaving a main station.
However, if you are ever really really stuck you can buy a ticket on the , but it’s not worth the risk (and the heavy fine) to travel without a ticket. Walk to the first carriage and proactively stop the uniformed attendant to let them know you have to buy a ticket.
That's a comparison we recommend making before you buy.
If you buy an on-line print-at-home ticket, it will be printed on a piece of 8 1/2 by 11 paper that will not fit in the stamping machines.