We discuss thermal rectification and thermoelectric energy conversion from the perspective of nonequilibrium statistical mechanics and dynamical systems theory. After preliminary considerations on the dynamical foundations of the phenomenological Fourier law in classical and quantum mechanics, we illustrate ways to control the phononic heat flow and design thermal diodes. Finally, we consider the coupled transport of heat and charge and discuss several general mechanisms for optimizing the figure of merit of thermoelectric efficiency.