$maileroptions = array('logger' => $logger1, 'format' => array('locale' => '', 'deflocale' => 'en', 'templateprocessorclass' => null, 'templatecompiledir' => $thisdir . '/email_tmp/', 'templatespath' => $thisdir . '/email_intern_templates/'), 'mailsystem' => 'smtp', 'smtp_host' => 'smtp_host', 'smtp_port' => 25, 'smtp_secure' => false, 'smtp_auth' => true, 'smtp_user' => 'smtp user', 'smtp_password' => 'smtp password'); // make email sending object switch ($mailertype) { case 'phpmailer': $mailer = new \Gelembjuk\Mail\PHPMailer(); break; case 'phpnative': $mailer = new \Gelembjuk\Mail\PHPNative(); break; default: $mailer = new \Gelembjuk\Mail\NullMail(); // check if log file is writable as } // init email processor $mailer->initMailer($maileroptions); // ===================== TEST SECTION ================================= $contactdata = array('name' => 'John Smith', 'message' => 'This is my contact message'); // SEND CONTACT EMAIL in default locale (en) $mailer->formatAndSendEmail('contact', $contactdata, '*****@*****.**', '*****@*****.**'); // now set `de` locale and send again German copy of email $mailer->setFormatterOption('locale', 'de'); // send same email but now templates must be from different locale $mailer->formatAndSendEmail('contact', $contactdata, '*****@*****.**', '*****@*****.**'); // now set `fr` locale and send again French copy of email $mailer->setFormatterOption('locale', 'fr'); // send same email but now templates must be from different locale $mailer->formatAndSendEmail('contact', $contactdata, '*****@*****.**', '*****@*****.**'); echo 'All emails were sent. '; if ($mailertype == 'null') { echo 'Check log file to see results'; }