What you need to do before boarding your train in Italy depends on whether you have a train ticket or a rail pass.

If You Have a Train Ticket

As of August 2016, Trenitalia high speed tickets ("Freccia..." type) and regional trains that are purchased online no longer need to be validated before you board the train. This is because tickets now have a specific date and four-hour window of time in which they're valid. When you purchase a ticket online, you'll need to choose a travel date and time. This means you can simply arrive at the train station, find your train, and get right on board.

Regional tickets that are purchased at the station, however, only come with a date but no time. These tickets must still be validated using the machines typically found inside the station or on the platforms. This validation must take place before you board the train - there's nowhere to validate a ticket on the train, and you'll incur a fine if your ticket isn't validated. Failure to validate a ticket purchased in a vending machine at the station prior to boearding the train might result in a high fine to the passenger.

Note that tickets for Trenitalia's high-speed trains always come with reservations, which means they didn't need to be validated before and they still don't need to be validated.

If You Have a Rail Pass

Your rail pass functions as a ticket, and you will need to get it validated at a station ticket window before you use it the first time. This cannot be done at a machine or by the conductor, so be sure to allot enough time when you arrive at the station before your first train trip for any potentially long lines at the ticket office.