public function send() { $this->validate(); $credentials = Symphony::Configuration()->get('postmarkapp'); $email = new Mail_Postmark($credentials['api_key'], $credentials['from_name'], $credentials['from_address']); $email->to($this->recipient)->replyTo($this->sender_email_address, $this->sender_name)->subject($this->subject)->messagePlain($this->message)->send(); return true; }
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(); }
/** * Sends the messages and clears the queue */ public function send() { $result = parent::send(); $this->_messages = array(); return $result; }
/** * 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; } }
/** * Setup postmark app and check for configuration * * @throws PostmarkMailerException * @return Mail_Postmark */ private function setupPostmark($to, $from, $subject, $content, $attachedFiles = false, $customheaders = false) { $required = array('POSTMARKAPP_API_KEY', 'POSTMARKAPP_MAIL_FROM_ADDRESS'); foreach ($required as $const) { if (!defined($const)) { user_error('Please define ' . $const, E_USER_ERROR); } } require_once dirname(dirname(dirname(__FILE__))) . '/thirdparty/postmark-php/Postmark.php'; $mail = Mail_Postmark::compose()->subject($subject); $to = self::parse_email_addresses($to); if (!$to) { throw new PostmarkMailerException('No recipient set for email.', E_USER_ERROR); } foreach ($to as $address) { $mail->addTo($address); } if ($attachedFiles) { foreach ($attachedFiles as $file) { $mail->addAttachment(Controller::join_links(Director::absoluteBaseURL(), $file->Filename)); } } if ($customheaders) { foreach (array('Cc', 'Bcc') as $header) { if (isset($customheaders[$header])) { $addresses = self::parse_email_addresses($customheaders[$header]); if ($addresses) { foreach ($addresses as $address) { $func = "add{$header}"; $mail->{$func}($address); } } } } } return $mail; }
function sendemail($fromname, $fromaddress, $toemail, $subject, $body, $tag = null) { Mail_Postmark::compose()->from($fromaddress, $fromname)->to($toemail)->subject($subject)->messagePlain($body)->tag($tag)->send(); }
public static function setupDefaults(Mail_Postmark &$mail) { $mail->from('*****@*****.**', 'Foo Bar'); }
public function testCompose() { $this->assertIsA(Mail_Postmark::compose(), 'Mail_Postmark'); }
public function setUp() { $this->_mail = Mail_Postmark::compose()->debug(Mail_Postmark::DEBUG_RETURN)->to('*****@*****.**', 'John Smith')->subject('The subject')->messagePlain('Test message'); }
/** * Sends the email, either with the native {@link Email} class or with Postmark * * @param array The form data * @param Form The form object */ public function sendEmail($data, $form) { $proxy = $form->proxy; $emailTo = $proxy->getToAddress(); $emailSubject = $proxy->getMessageSubject(); $replyTo = $proxy->getReplyTo(); $emailTemplate = $proxy->getEmailTemplate(); $fields = ArrayList::create(array()); $uploadedFiles = array(); foreach ($form->Fields()->dataFields() as $field) { if (!in_array($field->getName(), $proxy->getOmittedFields())) { if ($field instanceof CheckboxField) { $value = $field->value ? _t('ContactForm.YES', 'Yes') : _t('ContactForm.NO', 'No'); } elseif (class_exists("UploadifyField") && $field instanceof UploadifyField) { $uploadedFiles[] = $field->Value(); } else { $value = nl2br($field->Value()); } if (is_array($value)) { $answers = ArrayList::create(array()); foreach ($value as $v) { $answers->push(ArrayData::create(array('Value' => $v))); } $answers->Checkboxes = true; $fields->push(ArrayData::create(array('Label' => $field->Title(), 'Values' => $answers))); } else { $title = $field->Title() ? $field->Title() : $field->getName(); $fields->push(ArrayData::create(array('Label' => $title, 'Value' => $value))); } } } $messageData = array('IntroText' => $proxy->getIntroText(), 'Fields' => $fields, 'Domain' => Director::protocolAndHost()); Requirements::clear(); $html = $this->owner->customise($messageData)->renderWith($emailTemplate); Requirements::restore(); if ($proxy->isPostmark()) { require_once Director::baseFolder() . "/contact_form/code/thirdparty/postmark/Postmark.php"; $email = Mail_Postmark::compose()->subject($emailSubject)->messageHtml($html); try { $email->addTo($emailTo); } catch (Exception $e) { $form->sessionMessage(_t('ContactForm.BADTOADDRESS', 'It appears there is no receipient for this form. Please contact an administrator.'), 'bad'); return $this->owner->redirectBack(); } if ($replyTo) { try { $email->replyTo($replyTo); } catch (Exception $e) { } } foreach ($uploadedFiles as $file_id) { if ($file = File::get()->byID($file_id)) { $email->addAttachment($file->getFullPath()); } } } else { $email = Email::create(null, $emailTo, $emailSubject, $html); if ($replyTo) { $email->replyTo($replyTo); } foreach ($uploadedFiles as $file_id) { if ($file = File::get()->byID($file_id)) { $email->attachFile($file->getFullPath(), basename($file->Filename)); } } } $email->send(); foreach ($uploadedFiles as $file_id) { if ($file = File::get()->byID($file_id)->first()) { $file->delete(); } } }
$data = array('created' => date('Y-m-d H:i:s'), 'creator' => userid(), 'email' => $db->escape($_REQUEST['email'])); $user_id = $db->insert('user', $data); $invitation_code = $user_id + 110000; $db->update('user', array('invitation_code' => $invitation_code), array('id' => $user_id)); $link = config('application.domain') . config('application.baseurl') . 'auth/' . $invitation_code; $text = "I invite you to collaborate on the " . $project['name'] . " project.\n\nClick on the following link to create an account for Clarify and open the project\n" . $link . "\n\nCheers\n" . user('name') . " & the Clarify team"; } else { $link = config('application.domain') . config('application.baseurl') . 'project/' . userid() . '/' . $project['slug']; $text = "I invite you to collaborate on the " . $project['name'] . " project.\n\nClick on the following link to open the project\n" . $link . "\n\nCheers\n" . user('name') . " & the Clarify team"; $user_id = $user['id']; } // add permission for this project $permission = array('created' => date('Y-m-d H:i:s'), 'creator' => userid(), 'project' => $project_id, 'user' => $user_id, 'permission' => 'EDIT'); $db->insert('project_permission', $permission); // send e-mail invitation to collaborator $email = new Mail_Postmark(); $email->addTo($_REQUEST['email'])->subject(user('name') . ' invites you to collaborate on the "' . $project['name'] . '" project')->messagePlain($text)->send(); $data['id'] = $id; echo json_encode($data); break; } else { header('The goggles, they do nawtink!', true, 400); echo 'Please enter a valid e-mail address. You know, with @ and all that stuff...'; break; } case API_COLLABORATOR_REMOVE: $id = intval($route[4]); $collaborator = $db->single("SELECT project FROM project_collaborator WHERE id = '" . $id . "' LIMIT 1"); $db->query("DELETE FROM project_collaborator WHERE id = '" . $id . "' AND creator = '" . userid() . "' LIMIT 1"); $db->query("DELETE FROM project_permission WHERE project = '" . $collaborator['project'] . "' LIMIT 1"); header('Content-Type: application/json');
$contents_checkins_lifetime .= join(',', $item) . "\n"; // Create a new row of data and append it to the last row $item = ''; // 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);
<?php require 'includes/master.inc.php'; error_log(print_r($_POST, true)); $db = Database::getDatabase(); foreach ($_POST as $key => $val) { $_POST[$key] = mysql_real_escape_string($val, $db->db); } $dt = date('Y-m-d H:i:s'); $query = "INSERT INTO shine_feedback (appname, appversion, systemversion, email, reply, `type`, message, importance, critical, dt, ip, `new`, reguser, regmail) VALUES\n ('{$_POST['appname']}',\n '{$_POST['appversion']}',\n '{$_POST['systemversion']}',\n '{$_POST['email']}',\n '{$_POST['reply']}',\n '{$_POST['type']}',\n '{$_POST['message']}',\n '{$_POST['importance']}',\n '{$_POST['critical']}',\n '{$dt}',\n '{$_SERVER['REMOTE_ADDR']}',\n '1',\n '{$_POST['reguser']}',\n '{$_POST['regmail']}')"; mysql_query($query, $db->db) or die('error'); $link = 'http://shine.clickontyler.com/feedback-view.php?id=' . $db->insertId(); $message = "{$link}\n\n"; $message .= "From: {$_POST['email']}\n"; $message .= "Version: {$_POST['appversion']}\n"; $message .= "System Version: {$_POST['systemversion']}\n"; $message .= "Importance: {$_POST['importance']}\n"; $message .= "Criticality: {$_POST['critical']}\n\n"; $message .= "Message: " . str_replace("\\n", "\n", $_POST['message']) . "\n\n"; // Login to Shine and visit your settings to set of_email... $of_email = get_option('of_email', ''); if (strlen($of_email) > 0) { Mail_Postmark::compose()->addTo($of_email)->subject($_POST['appname'] . ' ' . ucwords($_POST['type']))->messagePlain($message)->send(); } echo "ok";
public function emailLicense() { Mail_Postmark::compose()->addTo($this->order->payer_email)->subject($this->application->email_subject)->messagePlain($this->application->getBody($this->order))->send(); }
public function emailLicense() { Mail_Postmark::compose()->addTo($this->order->payer_email)->subject($this->application->email_subject)->messagePlain($this->application->getBody($this->order))->addCustomAttachment($this->application->license_filename, $this->order->license, 'text/plain')->send(); }