San Marino has no airport and no railway station, so you will arrive by road.
From Rimini -- The easiest approach is from Rimini, 22 km away on the Italian Adriatic coast. Bonelli Bus runs a regular service from Rimini train station (the stop is across the road, in front of the Napoleon Hotel) to San Marino's bus terminal near the historic center. The journey takes about 50 minutes and costs around 6 EUR each way. Services run several times daily, with a reduced schedule on Sundays and holidays. Rimini itself is well connected by train to Bologna, Florence, and other Italian cities.
From Bologna -- Bologna's Guglielmo Marconi Airport is the nearest major international airport, about 135 km away. From Bologna, take a train to Rimini (about 1-1.5 hours) and then the bus to San Marino.
By car -- San Marino is easy to reach by car from the Italian motorway system. There is no border control. Parking is available outside the old town walls, with the main car parks at P1 and P2 near the bus terminal. In summer, parking fills up quickly on weekends.
A cable car connects the town of Borgo Maggiore at the base of Monte Titano to the historic center of San Marino at the top. If you arrive by car or bus to Borgo Maggiore, this is a scenic and convenient way up.