/** * Constructor * * @param mixed $content Lang instance or subject as string */ public function __construct($content = 'No subject') { parent::__construct($content); $admins = Config::get('admin_email'); if (!is_array($admins)) { $admins = array_filter(array_map('trim', explode(',', $admins))); } foreach ($admins as $email) { $this->to($email); } }
/** * Allows to send invitation by mpaikl * * @param PadComponent $pad The pad * @param array $activeEmails Mails list */ private function sendPadInformationsByMail($pad, $emails, $template, $infos, $attachment = null) { // Translate mail parts $email_translation = call_user_func_array(array(Lang::translateEmail($template, null), 'replace'), $infos); // Build mail with body and footer $mail = new ApplicationMail(new Translation(array('subject' => (string) $email_translation->subject->out(), 'plain' => $email_translation->plain, 'html' => $email_translation->html))); // Add recipients if (is_array($emails)) { foreach ($emails as $email) { $mail->to($email); } } else { $mail->to($emails); } if (!is_null($attachment)) { $mail->attach($attachment); } $mail->send(); }
/** * Prepare mail to be sent to recipient * * @param string $translation_id * @param mixed $to recipient * @param mixed * translation args * * @return ApplicationMail */ public static function prepare($translation_id, $to) { $vars = array_slice(func_get_args(), 2); if (!is_scalar($to)) { array_unshift($vars, $to); } // compute lang from arguments $lang = null; if (is_object($to) && $to instanceof User) { $lang = $to->lang; $to = $to->email; } // Translate mail parts $email_translation = call_user_func_array(array(Lang::translateEmail($translation_id, $lang), 'replace'), $vars); // Build mail with body and footer $plain = $email_translation->plain->out(); $html = $email_translation->html->out(); // No need for translatable emails if only one language available ... if (count(Lang::getAvailableLanguages()) > 1) { // Create object $translatable = self::create($translation_id, $vars); // Translate specific footer $footer_translation = Lang::translateEmail('translate_email_footer', $lang)->r($translatable); $plain .= "\n\n" . $footer_translation->plain->out(); $html .= "\n\n" . $footer_translation->html->out(); } $mail = new ApplicationMail(new Translation(array('subject' => $email_translation->subject->out(), 'plain' => $plain, 'html' => $html))); // Add recipient $mail->to($to); return $mail; }