public function errorEmail($e) { $email = new Mail_Postmark(); $email->subject('Inventory Site Error'); $email->addTo('*****@*****.**', 'Phil'); $body = ""; $body .= "There was an error:"; $body .= "File: " . $e->getFile() . "<br>"; $body .= "Line: " . $e->getLine() . "<br>"; $body .= "Message: " . $e->getMessage() . "<br>"; $body .= "Code: " . $e->getCode() . "<br>"; $body .= "Trace: " . $e->getTraceAsString() . "<br>"; $email->messageHtml($body); $email->send(); }
/** * overrides phpmailer::Send to send via the postmark api. * we'll pull the data we need from the phpmailer object * * @return (boolean) - whether or not sending via postmark api failed... **/ public function Send() { // make sure our constants have been defined... if (!defined('POSTMARKAPP_API_KEY') || !defined('POSTMARKAPP_MAIL_FROM_ADDRESS') || !defined('POSTMARKAPP_MAIL_FROM_NAME')) { // ...if nothing is defined, fall back to parent class Send method return parent::Send(); } // use PHP5 Reflection to get the private "$to" var out of // the phpmailer object... // http://www.php.net/manual/en/book.reflection.php $ref_class = new ReflectionClass('PHPMailer'); $ref_property = $ref_class->getProperty('to'); $ref_property->setAccessible(true); $phpmailers_to = $ref_property->getValue($this); // i miss teh nitrous $phpmailers_to = $phpmailers_to[0]; // remove empty elements in the array foreach ($phpmailers_to as $k => $v) { if ($v == "") { unset($phpmailers_to[$k]); } } // set a comma separated string of to addresses $postmark_to = implode(',', $phpmailers_to); // set up the other vars we need $postmark_subject = $this->Subject; $postmark_message_plain = $this->Body; // set up the postmark mail object $postmark_email = new Mail_Postmark(); $postmark_email->addTo($postmark_to); $postmark_email->subject($postmark_subject); $postmark_email->messagePlain($postmark_message_plain); // send it! try { $postmark_email->send(); return true; } catch (Exception $e) { $this->SetError($e->getMessage()); if ($this->exceptions) { throw $e; } return false; } }
// Clear the contents of the $row variable to start a new row //$contents_checkins .= implode(",",$row); //$contents_checkins .="\n"; // write line of csv file } // end while $msg .= "Checkins Lifetime successful\n"; } else { $contents_checkins_lifetime .= "no checkins Lifetime,"; $msg .= "Checkins Today Lifetime (No Results)\n"; } error_log("message" . $msg, 0); $email = new Mail_Postmark(); $email->addTo($output_mail, 'Grind Tech Output'); $email->addCc($destination_mail); $email->subject('Daily Reports'); $email->messagePlain('Attached are the Daily Grind Reports' . "\n" . "User report:\n" . 'https://members.grindspaces.com/reports/' . $filename1 . "\nLifetime check-ins report:\n" . 'https://members.grindspaces.com/reports/' . $filename3); file_put_contents('/var/www/vhosts/members.grindspaces.com/content/reports/' . $filename1, $contents_users); file_put_contents('/var/www/vhosts/members.grindspaces.com/content/reports/' . $filename3, $contents_checkins_lifetime); //$email->addCustomAttachment($filename1, $contents_users, $mimeType1); echo "Total Size " . strlen($content_users . $contents_checkins . $contents_checkins_lifetime); $email->addCustomAttachment($filename2, $contents_checkins, $mimeType2); //$email->addCustomAttachment($filename3, $contents_checkins_lifetime, $mimeType3); $email->debug($debug); $email->send(); } catch (Exception $e) { $msg .= 'Error occurred: Reason: ' + $e->getMessage() . '<br/>'; error_log('Daily Reporting: Failed. Reason: ' . $e->getMessage(), 0); return false; } // end try catch