You need a car. There is no train or bus service to Dover-Foxcroft, and no realistic way to reach it without driving. The nearest commercial airport is Bangor International Airport, roughly two hours to the south and east; from Bangor, take Route 15 or Route 6 north through the hills and you will arrive in Dover-Foxcroft.
Fill up on gas in Bangor, or at minimum in Dover-Foxcroft itself, before heading further north. Fuel stations become sparse quickly once you pass through town, and prices rise as you go deeper into the backcountry. The same goes for cash, phone signal, and most other things you might take for granted closer to the coast.