/** * @param array $settings_options_values * @param FW_Ext_Mailer_Email $email * @param array $data * @return bool|WP_Error */ public function send(FW_Ext_Mailer_Email $email, $settings_options_values, $data = array()) { if (!class_exists('PHPMailer')) { require_once ABSPATH . WPINC . '/class-phpmailer.php'; } $config = self::prepare_settings_options_values($settings_options_values); if (is_wp_error($config)) { return $config; } $mailer = new PHPMailer(); $mailer->isSMTP(); $mailer->IsHTML(true); $mailer->Host = $config['host']; $mailer->Port = $config['port']; $mailer->SMTPSecure = $config['secure']; $mailer->SMTPAuth = true; $mailer->Username = $config['username']; $mailer->Password = $config['password']; $mailer->CharSet = 'utf-8'; $mailer->From = $email->get_from(); $mailer->FromName = $email->get_from_name(); if (is_array($email->get_to())) { foreach ($email->get_to() as $to_address) { $mailer->AddAddress($to_address); } } else { $mailer->AddAddress($email->get_to()); } $mailer->Subject = $email->get_subject(); $mailer->Body = $email->get_body(); //$mailer->SMTPDebug = true; $result = $mailer->send(); $mailer->ClearAddresses(); $mailer->ClearAllRecipients(); unset($mailer); return $result ? true : new WP_Error('failed', __('Could not send the email', 'fw')); }
/** * @param array $settings_options_values * @param FW_Ext_Mailer_Email $email * @param array $data * @return bool|WP_Error */ public function send(FW_Ext_Mailer_Email $email, $settings_options_values, $data = array()) { $result = wp_mail($email->get_to(), $email->get_subject(), $email->get_body(), array('Content-type: text/html; charset=utf-8', 'From:' . htmlspecialchars($email->get_from_name(), null, 'UTF-8') . ' <' . htmlspecialchars($email->get_from(), null, 'UTF-8') . '>')); return $result ? true : new WP_Error('failed', __('Could not send the email', 'fw')); }