This paper presents a mixed-integer linear programming (MILP) model for the optimal energy management of residential microgrids, modeled as unbalanced, three-phase, electrical distribution system (EDS). Initially, the problem is formulated as a mixed-integer nonlinear programming (MINLP) problem. Then, a set of linear approximations and equivalent mathematical representations are used to obtain a precise MILP model. The proposed formulation considers three-phase generation units (GU), single-phase photovoltaic (PV) resources, and single-phase energy storage systems (ESS), as well as load management. The aim of the proposed model is to minimize the final operational costs of the microgrid while considering operational constraints of the EDS and an unexpected outage of the main grid through a security-constrained set of equations. The optimal solution of the MILP model is found using commercial convex optimization solvers. The proposed model was tested in a residential, three-phase EDS. Results show that the proposed linearizations and approximations produce accurate solutions when compared with a nonlinear three-phase OPF formulation, with an error in the objective function near to 2% and a maximum error in the voltage near to 1%. Efficiency and flexibility of the proposed methodology are also discussed.