Transport through a one-dimensional wire of interacting electrons connected to semi infinite leads is investigated using a bosonization approach. The dynamic nonlocal conductivity is rigorously expressed in terms of the transmission. For abrupt variations of the interaction parameters at the junctions, an incident electron is transmitted as a sequence of partial charges: the central wire acts as a Fabry-Pérot resonator. The dc conductance is shown to be given by the total transmission which turns out to be perfect. When the wire has a tendency towards superconducting order, partial Andreev reflection of an incident electron occurs. Finally, we study the role of a weak barrier at one contact or inside the wire by a renormalization group method at finite temperature. We compute the conductance in the presence of localized or extended disorder, and compare our results to recent experiments on quantum wires.