当前位置: 首页>>代码示例>>PHP>>正文


PHP Utilities::SendEmailFromFile方法代码示例

本文整理汇总了PHP中Utilities::SendEmailFromFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Utilities::SendEmailFromFile方法的具体用法?PHP Utilities::SendEmailFromFile怎么用?PHP Utilities::SendEmailFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utilities的用法示例。


在下文中一共展示了Utilities::SendEmailFromFile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post


//.........这里部分代码省略.........
             return new Tonic\Response(Tonic\Response::BADREQUEST);
         }
     } else {
         // get an authuser
         $authUser = new AuthUser();
         if ($authUser->UserId && $authUser->IsSuperAdmin == true) {
             // check if authorized
             $userId = $authUser->UserId;
         } else {
             return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
         }
     }
     // defaults
     $domain = SITE_URL;
     $domain = str_replace('{{friendlyId}}', $friendlyId, $domain);
     $logoUrl = 'sample-logo.png';
     $altLogoUrl = '';
     if ($s_passcode == PASSCODE) {
         $isFriendlyIdUnique = Site::IsFriendlyIdUnique($friendlyId);
         // check for reserved names
         if ($friendlyId == 'app' || $friendlyId == 'sites' || $friendlyId == 'api' || $friendlyId == 'triangulate' || $friendlyId == 'developer') {
             $isFriendlyIdUnique = false;
         }
         if ($isFriendlyIdUnique == false) {
             return new Tonic\Response(Tonic\Response::CONFLICT);
         }
         // default is blank
         $welcomeEmail = '';
         $receiptEmail = '';
         // files for emails
         $welcome_file = APP_LOCATION . '/site/emails/welcome.html';
         $receipt_file = APP_LOCATION . '/site/emails/receipt.html';
         // make sure the welcome email exists
         if (file_exists($welcome_file)) {
             // get default email file
             $welcomeEmail = file_get_contents($welcome_file);
         }
         // make sure the receipt email exists
         if (file_exists($receipt_file)) {
             // get default email file
             $receiptEmail = file_get_contents($receipt_file);
         }
         // add the site
         $site = Site::Add($domain, $name, $friendlyId, $logoUrl, $altLogoUrl, $theme, $email, $timeZone, $language, $direction, $welcomeEmail, $receiptEmail);
         // add the admin
         if ($email != '') {
             $isActive = 1;
             // admins by default are active
             $user = User::Add($email, $password, $firstName, $lastName, 'Admin', $userLanguage, $isActive, $site['SiteId']);
             $userId = $user['UserId'];
         }
         // set $siteId
         $siteId = $site['SiteId'];
         // publishes a theme for a site
         Publish::PublishTheme($site, $theme);
         // publish default content for the theme
         Publish::PublishDefaultContent($site, $theme, $user['UserId']);
         // publish the site
         Publish::PublishSite($site['SiteId']);
         // create a locale directory
         $locales_dir = SITES_LOCATION . '/' . $site['FriendlyId'] . '/locales';
         // create locales directory if it does not exist
         if (!file_exists($locales_dir)) {
             mkdir($locales_dir, 0755, true);
         }
         // set directory for locale
         $locale_dir = $locales_dir . '/' . $site['Language'] . '/';
         // make the locale dir if it does not exist
         if (!file_exists($locale_dir)) {
             mkdir($locale_dir, 0755, true);
         }
         // set filename
         $filename = 'translation.json';
         if (!file_exists($locale_dir . $filename)) {
             // create a blank translation file
             Utilities::SaveContent($locale_dir, $filename, '{}');
         }
         // send welcome email
         if (SEND_WELCOME_EMAIL == true && $email != '') {
             $to = $email;
             $from = EMAILS_FROM;
             $fromName = EMAILS_FROM_NAME;
             $subject = WELCOME_EMAIL_SUBJECT;
             $file = WELCOME_EMAIL_FILE;
             // create strings to replace
             $loginUrl = APP_URL . '/login/' . $site['FriendlyId'];
             $newSiteUrl = $domain;
             $replace = array('{{brand-logo}}' => '<img src="' . BRAND_LOGO . '" style="max-height:50px">', '{{brand}}' => BRAND, '{{reply-to}}' => EMAILS_FROM, '{{new-site-url}}' => $newSiteUrl, '{{login-url}}' => $loginUrl);
             // send email from file
             Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
         }
         // send new site hook
         Webhooks::NewSite($site);
         // send new user hook
         Webhooks::NewUser($user);
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:bladep911,项目名称:respond,代码行数:101,代码来源:site.php

示例2: post


//.........这里部分代码省略.........
             $customerId = $customer->id;
             Site::EditCustomer($site['SiteUniqId'], $customerId);
         }
         // read the defaults file
         $default_json_file = '../themes/' . $theme . '/default.json';
         // set $siteId
         $siteId = $site['SiteId'];
         // check to make sure the defaults.json exists
         if (file_exists($default_json_file)) {
             // get json from the file
             $json_text = file_get_contents($default_json_file);
             // decode json
             $json = json_decode($json_text, true);
             // pagetypes
             $pagetypes = array();
             // menu counts
             $primaryMenuCount = 0;
             $footerMenuCount = 0;
             // walk through defaults array
             foreach ($json as &$value) {
                 // get values from array
                 $url = $value['url'];
                 $source = $value['source'];
                 $name = $value['name'];
                 $description = $value['description'];
                 $layout = $value['layout'];
                 $stylesheet = $value['stylesheet'];
                 $primaryMenu = $value['primaryMenu'];
                 $footerMenu = $value['footerMenu'];
                 if (strpos($url, '/') !== false) {
                     // the url has a pagetype
                     $arr = explode('/', $url);
                     // get friendly ids from $url
                     $pageTypeFriendlyId = $arr[0];
                     $pageFriendlyId = $arr[1];
                     $pageTypeId = -1;
                     $pageType = PageType::GetByFriendlyId($pageTypeFriendlyId, $siteId);
                     // create a new pagetype
                     if ($pageType == NULL) {
                         $pageType = PageType::Add($pageTypeFriendlyId, 'Page', 'Pages', $layout, $stylesheet, 0, $siteId, $userId, $userId);
                     }
                     // get newly minted page type
                     $pageTypeId = $pageType['PageTypeId'];
                 } else {
                     // root, no pagetype
                     $pageFriendlyId = $url;
                     $pageTypeId = -1;
                 }
                 // create a page
                 $page = Page::Add($pageFriendlyId, $name, $description, $layout, $stylesheet, $pageTypeId, $site['SiteId'], $userId);
                 // set the page to active
                 Page::SetIsActive($page['PageUniqId'], 1);
                 // build the content file
                 $filename = '../themes/' . $theme . '/' . $source;
                 $content = '';
                 // get the content for the page
                 if (file_exists($filename)) {
                     $content = file_get_contents($filename);
                     // fix images
                     $content = str_replace('{{site-dir}}', 'sites/' . $site['FriendlyId'], $content);
                 }
                 // publish the fragment
                 Publish::PublishFragment($site['FriendlyId'], $page['PageUniqId'], 'publish', $content);
                 // build the primary menu
                 if ($primaryMenu == true) {
                     MenuItem::Add($name, '', 'primary', $url, $page['PageId'], $primaryMenuCount, $site['SiteId'], $userId, $userId);
                     $primaryMenuCount++;
                 }
                 // build the footer menu
                 if ($footerMenu == true) {
                     MenuItem::Add($name, '', 'footer', $url, $page['PageId'], $footerMenuCount, $site['SiteId'], $userId, $userId);
                     $footerMenuCount++;
                 }
             }
         } else {
             return new Tonic\Response(Tonic\Response::BADREQUEST);
         }
         // publishes a theme for a site
         Publish::PublishTheme($site, $theme);
         // publish the site
         Publish::PublishSite($site['SiteUniqId']);
         // send welcome email
         if (SEND_WELCOME_EMAIL == true && $email != '') {
             $to = $email;
             $from = REPLY_TO;
             $fromName = REPLY_TO_NAME;
             $subject = BRAND . ': Welcome to ' . BRAND;
             $file = 'emails/new-user.html';
             // create strings to replace
             $loginUrl = APP_URL;
             $newSiteUrl = APP_URL . '/sites/' . $site['FriendlyId'];
             $replace = array('{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO, '{{new-site-url}}' => $newSiteUrl, '{{login-url}}' => $loginUrl);
             // send email from file
             Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
         }
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:eavesmonkey,项目名称:respond,代码行数:101,代码来源:site.php

示例3: post

 /**
  * @method POST
  */
 function post()
 {
     parse_str($this->request->data, $request);
     $txn_type = $request['txn_type'];
     $status = $request['payer_status'];
     $siteId = $request['custom'];
     $email = $request['payer_email'];
     $payerId = $request['payer_id'];
     $item_name = $request['item_name'];
     // parse domain
     preg_match('#\\((.*?)\\)#', $item_name, $match);
     $domain = $match[1];
     // get reference to site
     $site = Site::GetBySiteId($siteId);
     // response was "VERIFIED"
     if ($status == 'verified' && $txn_type == 'subscr_signup') {
         $provider = 'PayPal';
         $status = 'Active';
         $subscriptionId = $payerId;
         $customerId = $email;
         // subscribe to a plan
         Site::Subscribe($siteId, $status, $plan, $provider, $subscriptionId, $customerId);
         // send success email to user
         $to = $site['PrimaryEmail'];
         $from = REPLY_TO;
         $fromName = REPLY_TO_NAME;
         $subject = BRAND . ': Thank your for subscribing to ' . BRAND;
         $file = APP_LOCATION . '/emails/subscribe-success.html';
         $replace = array('{{brand-logo}}' => '<img src="' . BRAND_LOGO . '" style="max-height:50px">', '{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO);
         // send
         Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
         // send details email to admin
         $to = REPLY_TO;
         $from = REPLY_TO;
         $fromName = REPLY_TO_NAME;
         $subject = BRAND . ': New Subscriber';
         $file = APP_LOCATION . '/emails/subscribe-details.html';
         $replace = array('{{brand-logo}}' => '<img src="' . BRAND_LOGO . '" style="max-height:50px">', '{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO, '{{domain}}' => $domain, '{{siteid}}' => $site['SiteId'], '{{friendlyid}}' => $site['FriendlyId'], '{{provider}}' => $provider, '{{customerid}}' => $customerId);
         // send email from file
         Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
     } else {
         // IPN response was "INVALID"\
     }
     $response = new Tonic\Response(Tonic\Response::OK);
     $response->contentType = 'text/HTML';
     $response->body = 'Yah!!!';
     return $response;
 }
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:51,代码来源:transaction.php

示例4: array

                // create strings to replace
                $loginUrl = APP_URL;
                $newSiteUrl = APP_URL . '/sites/' . $site['FriendlyId'];
                $replace = array('{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO, '{{login-url}}' => $loginUrl);
                // send email from file
                Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
            }
        }
    }
    if ($event->type == 'invoice.payment_failed') {
        $invoice_id = $event->data->object->id;
        // https://stripe.com/docs/api#retrieve_customer
        $customer = Stripe_Customer::retrieve($event->data->object->customer);
        $site = Site::GetByCustomerId($customer->id);
        // email receipt to customer
        if (SEND_PAYMENT_FAILED_EMAIL == true) {
            $to = $site['PrimaryEmail'];
            $from = REPLY_TO;
            $subject = BRAND . ': Payment Failed';
            $file = 'emails/invoice-payment-failed.html';
            // create strings to replace
            $loginUrl = APP_URL;
            $newSiteUrl = APP_URL . '/sites/' . $site['FriendlyId'];
            $replace = array('{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO, '{{login-url}}' => $loginUrl);
            // send email from file
            Utilities::SendEmailFromFile($to, $from, $subject, $replace, $file);
        }
    }
} catch (Exception $e) {
    print $e->getMessage();
}
开发者ID:eavesmonkey,项目名称:respond,代码行数:31,代码来源:stripe.php

示例5: post

 /**
  * @method POST
  */
 function post()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         // parse request
         parse_str($this->request->data, $request);
         $site = Site::GetBySiteId($token->SiteId);
         $siteId = $site['SiteId'];
         $email = $site['PrimaryEmail'];
         $status = 'Unsubscribed';
         $plan = '';
         $provider = '';
         $subscriptionId = '';
         $customerId = $site['CustomerId'];
         // set API key
         Stripe::setApiKey(STRIPE_SECRET_KEY);
         // retrieve customer
         $customer = Stripe_Customer::retrieve($site['CustomerId']);
         // unsubscribe
         $cu->subscriptions->retrieve($site['SubscriptionId'])->cancel();
         // unsubscribe to a plan
         Site::Subscribe($siteId, $status, $plan, $provider, $subscriptionId, $customerId);
         // send success email to user
         $to = $site['PrimaryEmail'];
         $from = REPLY_TO;
         $fromName = REPLY_TO_NAME;
         $subject = BRAND . ': You have successfully unsubscribed to ' . BRAND;
         $file = APP_LOCATION . '/emails/unsubscribe-success.html';
         $replace = array('{{brand-logo}}' => '<img src="' . BRAND_LOGO . '" style="max-height:50px">', '{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO);
         // send
         Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
         // send details email to admin
         $to = REPLY_TO;
         $from = REPLY_TO;
         $fromName = REPLY_TO_NAME;
         $subject = BRAND . ': Unsubscribed';
         $file = APP_LOCATION . '/emails/unsubscribe-details.html';
         $replace = array('{{brand-logo}}' => '<img src="' . BRAND_LOGO . '" style="max-height:50px">', '{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO, '{{domain}}' => $domain, '{{siteid}}' => $site['SiteId'], '{{friendlyid}}' => $site['FriendlyId'], '{{provider}}' => $site['Provider'], '{{customerid}}' => $site['CustomerId']);
         // send email from file
         Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
         // return a json response
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:51,代码来源:site.php

示例6: post

 /**
  * @method POST
  */
 function post()
 {
     // parse request
     parse_str($this->request->data, $request);
     $email = $request['email'];
     $friendlyId = $request['friendlyId'];
     // get site
     $site = Site::GetByFriendlyId($friendlyId);
     // get user
     $user = User::GetByEmail($email, $site['SiteId']);
     // send email
     if ($user != null) {
         // set token
         $token = urlencode(User::SetToken($user['UserId']));
         // send email
         $to = $email;
         $from = REPLY_TO;
         $fromName = REPLY_TO_NAME;
         $subject = BRAND . ': Reset Password';
         $file = APP_LOCATION . '/emails/reset-password.html';
         // create strings to replace
         $resetUrl = APP_URL . '/#/reset/' . $site['FriendlyId'] . '/' . $token;
         $replace = array('{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO, '{{reset-url}}' => $resetUrl);
         // send email from file
         Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
         // return a successful response (200)
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         // return an unauthorized exception (401)
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:nboss,项目名称:respond,代码行数:35,代码来源:user.php

示例7: post


//.........这里部分代码省略.........
     }
     $listener = new IpnListener();
     $listener->use_curl = false;
     $listener->use_sandbox = $use_sandbox;
     $listener->use_ssl = true;
     try {
         $verified = $listener->processIpn();
     } catch (Exception $e) {
         // fatal error trying to process IPN.
         exit(0);
     }
     // IPN response was "VERIFIED"
     if ($verified) {
         $processor = 'PayPal';
         if ($use_sandbox == true) {
             $processor .= ' (sandbox)';
         }
         $processorTransactionId = $request['txn_id'];
         $processorStatus = $request['payment_status'];
         $email = $request['payer_email'];
         $payerId = $request['payer_id'];
         $name = $request['first_name'] . ' ' . $request['last_name'];
         $shipping = $request['mc_handling'];
         $fee = $request['mc_fee'];
         $tax = $request['tax'];
         $total = $request['mc_gross'];
         $currency = $request['mc_currency'];
         $num_items = 1000;
         if (isset($request['num_cart_items'])) {
             $num_items = $request['num_cart_items'];
         }
         $items = array();
         // line-items (for receipt)
         $line_items = '';
         // get items
         for ($x = 1; $x <= $num_items; $x++) {
             if (isset($request['item_number' . $x])) {
                 $arr_temp = explode('-', $request['item_number' . $x]);
                 // shipping type is the last item of the array
                 $item_shipping_type = $arr_temp[count($arr_temp) - 1];
                 // the sku is the last item less the type
                 $item_sku = str_replace('-' . $item_shipping_type, '', $request['item_number' . $x]);
                 $item_name = $request['item_name' . $x];
                 $item_sku = iconv("ISO-8859-1", "UTF-8", $item_name);
                 $item_name = iconv("ISO-8859-1", "UTF-8", $item_name);
                 $item_quantity = $request['quantity' . $x];
                 $item_total = $request['mc_gross_' . $x];
                 $item_price = floatval($item_total) / intval($item_quantity);
                 $item = array('SKU' => $item_sku, 'Name' => $item_name, 'ShippingType' => $item_shipping_type, 'Quantity' => $item_quantity, 'Price' => $item_price, 'Total' => $item_total);
                 $download_link = '';
                 if ($item_shipping_type == 'DOWNLOAD') {
                     $download_link = '<br><a href="http://' . $site['Domain'] . '/api/transaction/download/{{transactionUniqId}}/' . $item_sku . '">Download</a>';
                 }
                 // setup currency for line items
                 $item_total = $item_total . ' ' . $currency;
                 $item_price = $item_price . ' ' . $currency;
                 // add $ for total and price
                 if ($currency == 'USD') {
                     $item_total = '$' . $item_total;
                     $item_price = '$' . $item_price;
                 }
                 $line_items .= '<tr style="border-bottom: 1px solid #f0f0f0;"><td>' . $item_name . '<br><small>' . $item_sku . '</small>' . $download_link . '</td><td align="right">' . $item_price . '</td><td align="right">' . $item_quantity . '</td><td align="right">' . $item_total . '</td></tr>';
                 array_push($items, $item);
             }
         }
         $items_json = json_encode($items);
         $data_json = json_encode($_POST);
         // add a transaction
         $transaction = Transaction::Add($site['SiteId'], $processor, $processorTransactionId, $processorStatus, $email, $payerId, $name, $shipping, $fee, $tax, $total, $currency, $items_json, $data_json);
         // replace {{transactionUniqId}} in line_items
         $line_items = str_replace('{{transactionUniqId}}', $transaction['TransactionUniqId'], $line_items);
         $site_logo = '';
         if ($site['LogoUrl'] != '' && $site['LogoUrl'] != NULL) {
             $site_logo = '<img src="http://' . $site['Domain'] . '/files/' . $site['LogoUrl'] . '" style="max-height:50px">';
         }
         // setup currency for line items
         $shipping = $shipping . ' ' . $currency;
         $tax = $tax . ' ' . $currency;
         $total = $total . ' ' . $currency;
         // add $ for total and price
         if ($currency == 'USD') {
             $shipping = '$' . $shipping;
             $tax = '$' . $tax;
             $total = '$' . $total;
         }
         // send email
         $replace = array('{{site}}' => $site['Name'], '{{site-logo}}' => $site_logo, '{{reply-to}}' => $site['PrimaryEmail'], '{{line-items}}' => $line_items, '{{shipping}}' => $shipping, '{{tax}}' => $tax, '{{total}}' => $total);
         $subject = '[' . $site['Name'] . '] Receipt for your purchase from ' . $site['Name'] . ' (ID: ' . strtoupper($transaction['TransactionUniqId']) . ')';
         //$file = 'sites/'.$site['FriendlyId'].'/emails/receipt.html';
         $file = '/emails/receipt.html';
         // send email from file
         Utilities::SendEmailFromFile($email, $site['PrimaryEmail'], $site['Name'], $subject, $replace, $file);
     } else {
         // IPN response was "INVALID"\
     }
     $response = new Tonic\Response(Tonic\Response::OK);
     $response->contentType = 'text/HTML';
     $response->body = 'Yah!!!';
     return $response;
 }
开发者ID:eavesmonkey,项目名称:respond,代码行数:101,代码来源:transaction.php


注:本文中的Utilities::SendEmailFromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。