/**
  * 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;
 }
Esempio n. 2
0
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 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();
         }
     }
 }
Esempio n. 6
0
File: of.php Progetto: yuantw/Shine
<?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";
Esempio n. 7
0
 public function emailLicense()
 {
     Mail_Postmark::compose()->addTo($this->order->payer_email)->subject($this->application->email_subject)->messagePlain($this->application->getBody($this->order))->send();
 }
Esempio n. 8
0
 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();
 }