public static function send($from, $template, $params = [], $options = []) { if (!isset(self::$instance)) { self::$instance = new Email(); } if (is_string($from)) { $from = [$from]; } else { array_walk_recursive($from, function (&$value) { if (is_string($value)) { $value = htmlentities($value); } }); } array_walk_recursive($params, function (&$value) { if (is_string($value)) { $value = htmlentities($value); } }); $currentUserId = null; if (isset(Yii::app()->user)) { $currentUserId = Yii::app()->user->id; } $eb = EmailBuilder::load($template); $mails = []; foreach ($from as $key => $value) { $email = $key; if (is_numeric($key)) { $email = $value; } ## merge local parameters if (is_array($value)) { $params = array_merge($params, $value); } $params['to'] = $email; $params['isPreview'] = false; if (!self::$instance->validator->validateValue($email)) { ## when email is not valid, fails silently... continue; } $html = $eb->render($params); $mails[] = ['subject' => $eb->subject, 'body' => $html, 'to' => $email]; } ServiceManager::run('SendEmail', ['mails' => $mails]); }
public static function send($builder) { extract($builder); extract($params); /*$temp = Yii::getPathOfAlias("application.views.layouts.email.".$template).'.php'; ob_start(); include $temp; $body = ob_get_clean();*/ $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "mail.pendapatkita.com"; // SMTP server $mail->SMTPDebug = 0; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "mail.pendapatkita.com"; // sets the SMTP server $mail->Port = 587; // set the SMTP port for the GMAIL server $mail->Username = "******"; // SMTP account username $mail->Password = "******"; // SMTP account password $mail->SetFrom("*****@*****.**", "Pendapatkita"); $mail->AddReplyTo("*****@*****.**", "Admin Pendapatkita.com"); $mail->Subject = $subject; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML(EmailBuilder::render($template, $params)); $mail->IsHTML(true); $mail->AddAddress($to); if (!$mail->Send()) { //echo "Mailer Error: " . $mail->ErrorInfo; return false; } else { return true; //echo "Message sent!"; } }
<?php require_once "../framework/config/backend.config.php"; require_once _CORE_DIR_ . '/mailer.core.php'; require_once _CONTROLLERS_BACKEND_DIR_ . 'emails.controller.php'; $builder = new EmailBuilder(); $mailer = new Mailer(); #Administrators validation $administrators_controller->session_check(); #Check administrator privileges if (!$administrators_controller->module_check(1)) { $notifications->set("You dont have access to ADMINISTRATORS module.", "error", true); $common->redirect("home.php?"); die; } #Module name $current_module = basename(__FILE__); #Section title $smarty->assign("section_title", $builder->siteLabels('module') . ' | ' . $builder->siteLabels('action')); if ($_POST['action'] == 'edit_l10n') { $builder->updateL10n($_POST); } if ($_POST['action'] == 'edit_main') { $builder->updateTemplateDesc($_POST); header($_SERVER['HTTP_REFERER']); } if ($_GET['act'] == "main" || $_GET['act'] == null) { $smarty->assign('templates', $builder->collectTemplates()); $smarty->assign('add_link', $current_module . '?act=add'); $smarty->assign('del_link', $current_module . '?act=del&id='); $smarty->assign('edt_link', $current_module . '?act=edit&id=');
<html> <head> <title> Template Title </title> </head> <body> <div style='width:70%;height:80%;border:1px solid #bbb;display:block;margin:auto'> <div style='width;100%;padding:2%;border-bottom:1px solid #bbb'> <img src='<?php echo EmailBuilder::img($img[1]); ?> ' width='100' /> </div> <div style='width:100%;height:70%;padding:2%;display:block'> </div> <div style='width;100%;padding:2% 2%;border-top:1px solid #bbb'> </div> </div> </body> </html>
public function actionPreview($template) { $eb = EmailBuilder::load($template); echo $eb->render(['isPreview' => true]); }
<html> <head> <title> Template Title </title> </head> <body> <div style='width:70%;height:80%;border:1px solid #bbb;display:block;margin:auto'> <div style='width;100%;padding:2% 2%;border-bottom:1px solid #bbb'> HEADER </div> <div style='width:100%;height:70%;padding:2%;display:block'> <img src='<?php echo EmailBuilder::img('manjadda.jpg'); ?> ' /> </div> <div style='width;100%;padding:2% 2%;border-top:1px solid #bbb'> FOOTER </div> </div> </body> </html>
public function actionPreview() { $EmailBuilder = new EmailBuilder(); echo $EmailBuilder->render($_GET['template']); }
<?php session_start(); //ini_set('display_errors',1); require 'class/config.inc.php'; require_once 'app_code/config.inc.php'; require 'class/class.EmailBuilder.php'; require 'class/class_attachment.php'; $att = new Attachment(); $page = new basic_page(); /*******Checking Authentication****************/ $page->auth->Checklogin(); $notify = new Notification(); $e_builder = new EmailBuilder(); $ajax = new PHPLiveX(); $ajax->AjaxifyObjects(array("e_builder")); /**********************************************/ /*******Setting Page access Rules & checking Authorization****************/ /************************************************************************/ $page->setPageKeywords(''); $page->setPageDescription(''); $page->setPageTitle("EMAIL BUILDER"); $page->setActiveButton('7'); $page->setInnerNav(''); $page->SetDynamicCSS_1('main_style.php'); $page->SetDynamicCSS_2('form.php'); // each page should have it's own .css sheet. Link mulitple sheets here and below $page->setImportCss3('css/news.css'); //$page -> setImportCss4('css/message.css'); $page->SetDynamicCSS_3('css/message.php'); $page->setImportCss4('auto/style.css');