I think that the potencial problem could be in your sql. I would modify query like as
(added DISTINCT and removed ps_cart_product join)
$sql = 'SELECT DISTINCT c.id_cart, c.id_lang, cu.id_customer, c.id_shop, cu.firstname, cu.lastname, cu.email, ad.phone_mobile FROM '._DB_PREFIX_.'cart c LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_cart = c.id_cart) LEFT JOIN '._DB_PREFIX_.'order_history oh ON (oh.id_order = o.id_order) LEFT JOIN '._DB_PREFIX_.'address ad ON (c.id_customer = ad.id_customer) RIGHT JOIN '._DB_PREFIX_.'customer cu ON (cu.id_customer = c.id_customer) // RIGHT JOIN '._DB_PREFIX_.'cart_product cp ON (cp.id_cart = c.id_cart) // Why?? cp is not used in SELECT neither in WHERE WHERE DATE_SUB(CURDATE(),INTERVAL 90 DAY) <= c.date_add AND o.valid = 0 AND oh.id_order_state = "6" AND cu.newsletter = 1';