/** * @method POST */ function form() { // parse request parse_str($this->request->data, $request); $siteUniqId = SITE_UNIQ_ID; $pageUniqId = $request['pageUniqId']; $body = $request['body']; $site = Site::GetBySiteUniqId($siteUniqId); $page = Page::GetByPageUniqId($pageUniqId); if ($site != null && $page != null) { $subject = 'RespondCMS: Form Submission [' . $site['Name'] . ': ' . $page['Name'] . ']'; $content = '<h3>Site Information</h3>' . '<table>' . '<tr>' . '<td style="padding: 5px 25px 5px 0;">Site:</td>' . '<td style="padding: 5px 0">' . $site['Name'] . '</td>' . '</tr>' . '<tr>' . '<td style="padding: 5px 25px 5px 0;">Page:</td>' . '<td style="padding: 5px 0">' . $page['Name'] . '</td>' . '</tr>' . '</table>' . '<h3>Form Details</h3>' . $body; // send an email $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= 'From: ' . $site['PrimaryEmail'] . "\r\n" . 'Reply-To: ' . $site['PrimaryEmail'] . "\r\n"; // sends the email $to = $site['PrimaryEmail']; $from = $site['PrimaryEmail']; $fromName = $site['Name']; Utilities::SendEmail($to, $from, $fromName, $subject, $content); // return a successful response (200) return new Tonic\Response(Tonic\Response::OK); } else { // unauthorized access return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } }
public static function SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file, $site = NULL) { $full_file = $file; if (file_exists($full_file)) { $content = file_get_contents($full_file); // walk through and replace values in associative array foreach ($replace as $key => &$value) { $content = str_replace($key, $value, $content); $subject = str_replace($key, $value, $subject); } // send email if ($site != NULL) { Utilities::SendSiteEmail($site, $to, $from, $fromName, $subject, $content); } else { Utilities::SendEmail($to, $from, $fromName, $subject, $content); } } }
public static function SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file, $root = '../') { $full_file = $root . $file; if (file_exists($full_file)) { $content = file_get_contents($full_file); // walk through and replace values in associative array foreach ($replace as $key => &$value) { $content = str_replace($key, $value, $content); $subject = str_replace($key, $value, $subject); } Utilities::SendEmail($to, $from, $fromName, $subject, $content); } }