The macroscopic heterojunction materials under Fourier law can present a thermal rectification effect due to their asymmetrical property, where the opposite temperature dependence of thermal conductivity for two junctions plays a important role. Here we investigate the relation between the rectification ratio and the coefficients of the temperature-dependent thermal conductivities of the junctions. For heterojunction materials with linear temperature-dependent thermal conductivities, the maximal rectification ratio is predicted to be 0.5. For the quadratic temperature-dependent--thermal-conductivity case, the maximal rectification ratio can be improved to about 0.86. The thermal rectification can asymptotically approach a maximum value of 1 for high-order--temperature-dependent cases. To obtain the optimal thermal rectification, we present a temperature-dependent thermal-conductivity function law which gives practical guidance for searching an ideal thermal diode.