本文整理汇总了PHP中Newsletter::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Newsletter::save方法的具体用法?PHP Newsletter::save怎么用?PHP Newsletter::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newsletter
的用法示例。
在下文中一共展示了Newsletter::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create($catalog_id)
{
$rules = array('images' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::route(array('admin.newsletter.create', $catalog_id))->withErrors($validator)->With(Input::all());
} else {
$catalog = Catalog::find($catalog_id);
$pictures = $catalog->pictures;
$car = $catalog->car;
$images = Input::get('images');
$newsletter = new Newsletter();
$newsletter->title = $catalog->title;
$newsletter->images = $images;
$newsletter->send_to = 0;
$newsletter->user_id = Auth::user()->id;
$newsletter->catalog_id = $catalog_id;
$newsletter->save();
$settingsEmail = Settings::where('key', '=', 'contact_email')->first();
$settingsEmailName = Settings::where('key', '=', 'contact_name')->first();
// Subscribers::find(8001) for testing
$subscribers = Subscribers::all();
foreach ($subscribers as $subscriber) {
$data = array('subject' => $catalog->title, 'to' => $subscriber->email, 'to_name' => $subscriber->name, 'from_name' => $settingsEmailName->value, 'from' => $settingsEmail->value, 'catalog' => $catalog, 'images' => $images, 'car' => $car, 'pictures' => $pictures, 'user' => $subscriber);
Mail::queue('emails.newsletter.html', $data, function ($message) use($data) {
$message->to($data['to'], $data['to_name'])->from($data['from'], $data['from_name'])->subject($data['subject']);
});
}
return Redirect::route('admin.newsletter.index')->with('success', Lang::get('messages.newsletter_created'));
}
return Redirect::route('admin.newsletter.index')->with('success', Lang::get('messages.newsletter_created'));
}
示例2: createNewsletter
public function createNewsletter()
{
$validator = Validator::make(Input::all(), $this->rules);
if ($validator->passes()) {
$newsletter = new Newsletter();
$count = Newsletter::orderby('ID_Newsletter', 'DESC')->first();
$tampID = $count->ID_Newsletter;
$checkYear = substr(strval($tampID), 3, -5);
$incrementID = substr($tampID, 3) + 1;
$join = "NEW" . $incrementID;
$success = "Thank you for register to our newsletter, we will send you our newsletter to you, please check your folder spam as well";
date_default_timezone_set('Asia/Jakarta');
$date = date('Y-m-d h:i:s', time());
if ($checkYear == strval(date("y"))) {
$newsletter->ID_Newsletter = $join;
$newsletter->First_Name = Input::get('news-firstname');
$newsletter->Last_Name = Input::get('news-lastname');
$newsletter->Email = Input::get('news-email');
$newsletter->Date = $date;
$newsletter->Status = "Pending";
$newsletter->save();
return Redirect::to('/aboutus')->with('message', $success);
} else {
$testimonial = new Testimonial();
date_default_timezone_set('Asia/Jakarta');
$date = date('Y-m-d h:i:s', time());
$newsletter->ID_Newsletter = "NEW" . date('y') . "00001";
$newsletter->First_Name = Input::get('news-firstname');
$newsletter->Last_Name = Input::get('news-lastname');
$newsletter->Email = Input::get('news-email');
$newsletter->Date = $date;
$newsletter->Status = "Pending";
$newsletter->save();
return Redirect::to('/aboutus')->with('message', $success);
}
} else {
return Redirect::to('/aboutus')->withErrors($validator, 'newsletter')->withInput()->with('active', 'active');
}
}
示例3: actionNewsletter
public function actionNewsletter()
{
$news = new Newsletter();
if (isset($_POST['email'])) {
$news->email = $_POST['email'];
$news->active = 1;
if ($news->save()) {
$this->render('newletter-thankyou');
}
Yii::app()->end();
}
$news->validate();
$this->render('newletter-error', array('model' => $news));
}
示例4: add
public static function add($input, $cc_admin = false)
{
// set subject
$input['subject'] = '[BagiKasih] ' . $input['subject'];
// set sender
$input['sender_email'] = 'info@bagikasih.com';
$input['sender_name'] = 'BagiKasih';
// set status
$input['status'] = 0;
$newsletter = new Newsletter();
foreach ($input as $coulumn => $value) {
$newsletter->{$coulumn} = $value;
}
$newsletter->save();
try {
$data = array('content' => $newsletter->message);
if (!App::isLocal()) {
// send email
Mail::send('emails.blank', $data, function ($message) use($newsletter) {
$message->from($newsletter->sender_email, $newsletter->sender_name);
$message->to($newsletter->recipient_email, $newsletter->recipient_name);
if ($cc_admin) {
$message->cc('support@bagikasih.com');
}
$message->subject($newsletter->subject);
});
} else {
// echo View::make('emails.blank', $data);
}
$newsletter->status = 1;
$newsletter->save();
} catch (Exception $e) {
$newsletter->status = 2;
$newsletter->save();
}
return $newsletter;
}
示例5: doSave
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0;
// initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their corresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aSubscriberGroup !== null) {
if ($this->aSubscriberGroup->isModified() || $this->aSubscriberGroup->isNew()) {
$affectedRows += $this->aSubscriberGroup->save($con);
}
$this->setSubscriberGroup($this->aSubscriberGroup);
}
if ($this->aNewsletter !== null) {
if ($this->aNewsletter->isModified() || $this->aNewsletter->isNew()) {
$affectedRows += $this->aNewsletter->save($con);
}
$this->setNewsletter($this->aNewsletter);
}
if ($this->aUserRelatedByCreatedBy !== null) {
if ($this->aUserRelatedByCreatedBy->isModified() || $this->aUserRelatedByCreatedBy->isNew()) {
$affectedRows += $this->aUserRelatedByCreatedBy->save($con);
}
$this->setUserRelatedByCreatedBy($this->aUserRelatedByCreatedBy);
}
if ($this->aUserRelatedByUpdatedBy !== null) {
if ($this->aUserRelatedByUpdatedBy->isModified() || $this->aUserRelatedByUpdatedBy->isNew()) {
$affectedRows += $this->aUserRelatedByUpdatedBy->save($con);
}
$this->setUserRelatedByUpdatedBy($this->aUserRelatedByUpdatedBy);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例6: actionindex
/**
* Index action
*/
public function actionindex()
{
$model = new Newsletter();
$sent = false;
if (isset($_POST['Newsletter'])) {
$model->attributes = $_POST['Newsletter'];
if ($model->save()) {
$sent = true;
Yii::app()->user->setFlash('success', Yii::t('index', 'Thank you. You are now subscribed to our newsletter.'));
}
}
// Load facebook
Yii::import('ext.facebook.facebookLib');
$facebook = new facebookLib(array('appId' => Yii::app()->params['facebookappid'], 'secret' => Yii::app()->params['facebookapisecret'], 'cookie' => true, 'disableSSLCheck' => false));
facebookLib::$CURL_OPTS[CURLOPT_CAINFO] = Yii::getPathOfAlias('ext.facebook') . '/ca-bundle.crt';
$this->render('index', array('model' => $model, 'facebook' => $facebook, 'sent' => $sent));
}
示例7: createNewsletter
/**
* @before _secure, _admin
*/
public function createNewsletter()
{
$this->seo(array("title" => "Create Newsletter", "keywords" => "admin", "description" => "admin", "view" => $this->getLayoutView()));
$view = $this->getActionView();
$groups = \Group::all(array(), array("name", "id"));
if (count($groups) == 0) {
$this->_createGroup(array("name" => "All", "users" => json_encode(array("*"))));
$groups = \Group::all(array(), array("name", "id"));
}
if (RequestMethods::post("action") == "createNewsletter") {
$message = new Template(array("subject" => RequestMethods::post("subject"), "body" => RequestMethods::post("body")));
$message->save();
$newsletter = new Newsletter(array("template_id" => $message->id, "group_id" => RequestMethods::post("user_group"), "scheduled" => RequestMethods::post("scheduled")));
$newsletter->save();
$view->set("success", TRUE);
}
$view->set("groups", $groups);
}
示例8: actionCreate
public function actionCreate()
{
$model = new Newsletter('create');
if (isset($_POST['Newsletter'])) {
$model->attributes = $_POST['Newsletter'];
$model->created_time = date('Y-m-d H:i:s');
$send_time = str_replace("/", "-", $_POST['Newsletter']['send_time']);
$send_time = date('Y-m-d H:i:s', strtotime($send_time));
$model->send_time = $send_time;
if (!$model->save()) {
Yii::log(print_r($model, true), 'error', 'NewsletterController.actionCreate');
//throw new CHttpException(400, 'Error');
} else {
$res = $this->buildListSubscriberAdd($model);
$model->total_subscriber = $res['totalSubscriber'];
$model->remain_subscribers = $res['listIdSubsciber'];
$model->dedicate_list = implode(',', $model->newsletter_group_subscriber);
$model->save();
$this->saveGroupSubscriber($model);
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model, 'actions' => $this->listActionsCanAccess));
}
示例9: actionIndex
public function actionIndex()
{
$modelN=new Newsletter;
if(isset($_POST['Newsletter']))
{
$modelN->attributes=$_POST['Newsletter'];
$modelN->dtenvio = 'NOW()';
$modelN->save();
// buscar eventos que fazem parte da newsletter
$modelE = Evento::model();
$eventos = $modelE->getEventosProxNewsletterIt();
$criteria = new CDbCriteria();
// identificar o nr da última newsletter inserida
$sql = "select MAX(nr) FROM newsletter;";
$max=Yii::app()->db->createCommand($sql)->execute();
$evnews = new Eventosnewsletter;
// registar emails enviados
foreach( $eventos as $ev ){
$evnews->nr = $max;
$evnews->idevento = $ev->idevento;
$evnews->save();
$ev->proxnewsletter = 0;
$ev->save();
}
$this->redirect(array('//site/index'));
}
$model = Evento::model();
$this->render('index',array(
'data'=>$model->getEventosProxNewsletter(10),
));
}
示例10: duplicateNewsletter
public function duplicateNewsletter($iOriginalId)
{
$oNewsletter = NewsletterQuery::create()->findPk($iOriginalId);
if ($oNewsletter) {
$oNewNewsletter = new Newsletter();
$oNewNewsletter->setSubject('[Copy] ' . $oNewsletter->getSubject());
$oNewNewsletter->setNewsletterBody($oNewsletter->getNewsletterBody());
$oNewNewsletter->setLanguageId($oNewsletter->getLanguageId());
$oNewNewsletter->setIsHtml($oNewsletter->getIsHtml());
$oNewNewsletter->setTemplateName($oNewsletter->getTemplateName());
$oNewNewsletter->save();
return $oNewNewsletter->getId();
}
}
示例11: run_newsletter
function run_newsletter($task, $args)
{
ini_set("memory_limit", "2048M");
define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
define('SF_APP', 'frontend');
define('SF_ENVIRONMENT', 'prod');
define('SF_DEBUG', false);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
/*$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();*/
try {
$controler = sfContext::getInstance()->getController();
$newsletterHtml = $controler->getPresentationFor("news", "composeNewsletter");
$newsletter = new Newsletter();
$today = UtilsHelper::DateBG(date('Y-m-d H:i:s', time()), 'd F, Y г.');
$newsletter->setLabel($today);
$newsletter->setContent($newsletterHtml);
$newsletter->save();
$mailinglist = Document::getDocumentByExclusiveTag("newsletter_mailinglist_default");
if ($mailinglist) {
$subscribers = Document::getChildrenOf($mailinglist->getId(), "Subscriber");
}
$subject = "Sgrada.com - ежедневен бюлетин";
$i = $ind = 0;
$mailAddresses = array();
$cnt = count($subscribers);
foreach ($subscribers as $subscriber) {
$ind++;
if ($subscriber->getPublicationStatus() == "ACTIVE") {
$mailAddresses[] = $subscriber->getEmail();
echo " ====> " . $subscriber->getEmail() . "\n";
$i++;
}
if ($i == 100 || $ind == $cnt) {
if (!empty($mailAddresses)) {
//sendMail($mailAddresses, $subject, $newsletterHtml);
$mail = new sfMail();
$mail->initialize();
$mail->setMailer('sendmail');
$mail->setCharset('utf-8');
$mail->setSender(UtilsHelper::NO_REPLY_MAIL, UtilsHelper::SYSTEM_SENDER);
$mail->setFrom(UtilsHelper::NO_REPLY_MAIL, UtilsHelper::SYSTEM_SENDER);
$mail->addAddress(UtilsHelper::NO_REPLY_MAIL);
foreach ($mailAddresses as $mailAdd) {
$mail->addBcc($mailAdd);
}
$mail->setContentType('text/html');
$mail->setSubject($subject);
$mail->setBody($newsletterHtml);
$mail->send();
}
$mailAddresses = array();
$i = 0;
}
}
} catch (Exception $e) {
$newsletter->setLabel("ERROR! " . $today);
$newsletter->save();
FileHelper::Log("TASK run_newsletter: " . $e->getMessage(), UtilsHelper::MSG_ERROR);
}
}
示例12: actionIndex
/**
* Index action
*/
public function actionIndex()
{
// New subscriber form
$model = new Newsletter();
if (isset($_POST['Newsletter'])) {
$model->attributes = $_POST['Newsletter'];
if ($model->save()) {
Yii::app()->user->setFlash('success', Yii::t('newsletter', 'Email Added.'));
}
}
// Send newsletter
if (isset($_POST['sendnewsletter']) && $_POST['sendnewsletter']) {
// Make sure content exists
if (isset($_POST['content']) && $_POST['content'] != '') {
// Make sure there are enough email
$emails = Newsletter::model()->findAll();
if ($emails) {
$sent = 0;
// Loop and send
foreach ($emails as $row) {
$email = Yii::app()->email;
$email->subject = isset($_POST['subject']) ? $_POST['subject'] : 'Newsletter';
$email->to = $row->email;
$email->from = Yii::app()->params['emailout'];
$email->replyTo = Yii::app()->params['emailout'];
$email->message = $_POST['content'];
$email->send();
$sent++;
}
Yii::app()->user->setFlash('success', Yii::t('newsletter', '{count} Newsletter emails sent.', array('{count}' => $sent)));
} else {
Yii::app()->user->setFlash('error', Yii::t('newsletter', 'There are no subscribers to send the newsletter to.'));
}
} else {
Yii::app()->user->setFlash('error', Yii::t('newsletter', 'You must provide a valid content to email.'));
}
}
// Did we submit the form and selected items?
if (isset($_POST['bulkoperations']) && $_POST['bulkoperations'] != '') {
// Did we choose any values?
if (isset($_POST['record']) && count($_POST['record'])) {
// What operation we would like to do?
switch ($_POST['bulkoperations']) {
case 'delete':
// Load records
$records = Newsletter::model()->deleteByPk(array_keys($_POST['record']));
// Done
Yii::app()->user->setFlash('success', Yii::t('newsletter', '{count} items deleted.', array('{count}' => $records)));
break;
default:
// Nothing
break;
}
}
}
// Load items and display
$criteria = new CDbCriteria();
$count = Newsletter::model()->count();
$pages = new CPagination($count);
$pages->pageSize = self::PAGE_SIZE;
$pages->applyLimit($criteria);
$sort = new CSort('Newsletter');
$sort->defaultOrder = 'joined DESC';
$sort->applyOrder($criteria);
$sort->attributes = array('email' => 'email', 'joined' => 'joined');
$items = Newsletter::model()->findAll($criteria);
$this->render('index', array('model' => $model, 'rows' => $items, 'pages' => $pages, 'sort' => $sort, 'count' => $count));
}
示例13: newsletter
<?php
if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['nom'])) {
require_once '../../module/Connexion.php';
require_once '../../module/model/user.php';
require_once '../../module/model/newsletter.php';
# save the user into newsletter (auto ) ;)
$newslatter = new Newsletter($_POST['email']);
$newslatter->save();
$Doublemail = "";
# to check if the email is allredy exist
$name = isset($_POST['nom']) ? $_POST['nom'] : "";
$lname = isset($_POST['prenom']) ? $_POST['prenom'] : "";
$bd = isset($_POST['bd']) ? $_POST['bd'] : "";
$email = isset($_POST['email']) ? $_POST['email'] : "";
$password = isset($_POST['password']) ? $_POST['password'] : "";
$data = array('name' => $name, 'lname' => $lname, 'bd' => $bd, 'email' => $email, 'password' => $password);
$user = new User($data);
$result = $user->save();
if ($result == "existe") {
$Doublemail = "&&mail=duplicated";
}
if ($result == true && $result != "existe") {
header("location:../../../login?c=success");
} else {
if ($result == true && $result == "existe") {
header("location:../../../inscription?mail=duplicated");
} else {
header("location:../../../inscription?c=failed");
}
}
示例14: add_event
public function add_event()
{
try {
$_arData = array();
$_userData = Session::get('login');
$destinationPath_Events = 'asserts/images/Features';
$destinationPath_Header = 'asserts/images/Events';
$destinationPath_PDF = 'asserts/images/LabelsToLife';
$eventName = Input::get("eventName");
if (empty($eventName)) {
$eventName = '';
}
$eventShortTitle = Input::get("eventShortTitle");
if (empty($eventShortTitle)) {
$eventShortTitle = '';
}
$eventContent = Input::get("eventContent");
if (empty($eventContent)) {
$eventContent = '';
}
$eventVisible = Input::get("eventVisible");
if (empty($eventVisible)) {
$eventVisible = '0';
}
if ($eventVisible == '1') {
$eventVisible = '1';
} else {
$eventVisible = '0';
}
$filename_eventPictures = null;
if (Input::hasfile("file_eventPictures")) {
$file_eventPictures = Input::file("file_eventPictures");
$filename_eventPictures = $file_eventPictures->getClientOriginalName();
$upload_success_banner = $file_eventPictures->move($destinationPath_Events, $filename_eventPictures);
}
if (empty($filename_eventPictures)) {
$filename_eventPictures = '';
}
$filename_Banner = null;
if (Input::hasfile("file_bannerImage")) {
$file_Banner = Input::file("file_bannerImage");
$filename_Banner = $file_Banner->getClientOriginalName();
$upload_success_banner = $file_Banner->move($destinationPath_Header, $filename_Banner);
}
if (empty($filename_Banner)) {
$filename_Banner = '';
}
$filename_PDF = null;
if (Input::hasfile("file_eventPDF")) {
$file_PDF = Input::file("file_eventPDF");
$filename_PDF = $file_PDF->getClientOriginalName();
$upload_success_banner = $file_PDF->move($destinationPath_PDF, $filename_PDF);
}
if (empty($filename_PDF)) {
$filename_PDF = '';
}
if ($eventName == '' || $eventShortTitle == '' || $filename_eventPictures == '' || $filename_Banner == '' || $filename_PDF == '' || Input::get('success_story_id') == 'none' || Input::get('latest_news_id') == 'none' || Input::get('latest_events_id') == 'none' || Input::get('hot_stuff_id') == 'none' || Input::get('cool_stuff_id') == 'none') {
Session::flash('error', '$$$ --- Error : Please check required informations & all of events --- $$$');
return Redirect::to('qlm-admin/add-new-event');
} else {
$newsletter = new Newsletter();
$nsl_id = $this->getnewsletterid();
$newsletter->eventId = $nsl_id;
$newsletter->eventName = $eventName;
$newsletter->eventShortTitle = $eventShortTitle;
$newsletter->eventPictures = $filename_eventPictures;
$newsletter->bannerImage = $filename_Banner;
$newsletter->eventPDF = $filename_PDF;
$newsletter->eventPicturesContent = $filename_eventPictures;
$newsletter->eventVisible = $eventVisible;
$newsletter->eventDate = date("Y-m-d H:i:s");
$newsletter->eventEditor = $_userData["username"];
$newsletter->eventCreatedDate = date("Y-m-d H:i:s");
$newsletter->save();
if (Input::get('success_story_id') != 'none') {
$event_story = Events::where('eventId', Input::get('success_story_id'))->update(['nsl_id' => $nsl_id]);
}
if (Input::get('latest_news_id') != 'none') {
$event_story = Events::where('eventId', Input::get('latest_news_id'))->update(['nsl_id' => $nsl_id]);
}
if (Input::get('latest_events_id') != 'none') {
$event_story = Events::where('eventId', Input::get('latest_events_id'))->update(['nsl_id' => $nsl_id]);
}
if (Input::get('hot_stuff_id') != 'none') {
$event_story = Events::where('eventId', Input::get('hot_stuff_id'))->update(['nsl_id' => $nsl_id]);
}
if (Input::get('cool_stuff_id') != 'none') {
$event_story = Events::where('eventId', Input::get('cool_stuff_id'))->update(['nsl_id' => $nsl_id]);
}
}
} catch (Exception $_ex) {
Log::error('Error Add New Event : ' . $_ex->getMessage());
Session::flash('error', '$$$ --- Error (' . $_ex->getMessage() . ') --- $$$');
}
Session::flash('success', '$$$ --- Add New Newsletter Successfully --- $$$');
return Redirect::to('qlm-admin/add-new-event/' . $nsl_id);
}
示例15: save
function save($id = FALSE)
{
if ($_POST) {
$newsletter = new Newsletter($id);
$_POST['user_id'] = $this->session->userdata('id');
$newsletter->from_array($_POST);
$newsletter->save();
// หา email ของ member
$users = new User();
$users->where("newsletter like '%" . $newsletter->category_id . "%'")->get();
foreach ($users as $user) {
$email_member[] = $user->email;
}
// หา email nonmember
$newsletters_email_lists = new Newsletters_email_list();
$newsletters_email_lists->where("newsletter like '%" . $newsletter->category_id . "%'")->get();
foreach ($newsletters_email_lists as $newsletters_email_list) {
$email_nonmember[] = $newsletters_email_list->email;
}
// ###### PHPMailer ####
require_once "PHPMailer_v5.1/class.phpmailer.php";
// ประกาศใช้ class phpmailer กรุณาตรวจสอบ ว่าประกาศถูก path
require_once "PHPMailer_v5.1/class.smtp.php";
// ประกาศใช้ class phpmailer กรุณาตรวจสอบ ว่าประกาศถูก path
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'ssl://smtp.gmail.com';
$mail->Port = 465;
$mail->Username = 'thaigcd.morph.go.th@gmail.com';
$mail->Password = '1212312121';
$mail->SMTPAuth = true;
$mail->CharSet = "utf-8";
$mail->From = "thaigcd.morph.go.th@gmail.com";
// account e-mail ของเราที่ใช้ในการส่งอีเมล
$mail->FromName = "สำนักโรคติดต่อทั่วไป";
//$mail->AddAddress("unisexx@mail.com"); // Email ปลายทางที่เราต้องการส่ง
$mail->IsHTML(true);
// ถ้า E-mail นี้ มีข้อความในการส่งเป็น tag html ต้องแก้ไข เป็น true
$mail->Subject = $newsletter->title;
// หัวข้อที่จะส่ง
$mail->Body = $newsletter->detail;
// ข้อความ ที่จะส่ง
$mail->SMTPDebug = false;
$mail->do_debug = 0;
if ($_FILES['attachment']['name']) {
$_POST['attachment'] = $newsletter->upload($_FILES['attachment'], 'uploads/newsletter_attachment/');
$mail->AddAttachment('uploads/newsletter_attachment/' . $_POST['attachment']);
}
foreach ($email_nonmember as $email1) {
$mail->AddAddress($email1);
$mail->send();
/*
if (!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
*/
$mail->ClearAddresses();
//echo "$email1 <br>";
}
foreach ($email_member as $email2) {
$mail->AddAddress($email2);
$mail->send();
/*
if (!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
*/
$mail->ClearAddresses();
}
set_notify('success', 'ส่งเมล์ถึงสมาชิกเรียบร้อย');
}
redirect('newsletters/admin/newsletters');
}