public function form(SS_HTTPRequest $request)
 {
     /*		
     		echo "<pre>";
     		echo print_r($request);
     		echo "<hr>";
     		echo print_r($_POST);
     		echo "</pre>";
     		echo $_SERVER['HTTP_REFERER'];
     */
     $data = $_POST;
     $email = new Email();
     $email->setTo('*****@*****.**');
     $email->setFrom($data['Email']);
     $email->setSubject("Contact Message from " . $data["Name"]);
     $messageBody = "\n\t\t\t<p><strong>Name:</strong> {$data['Name']}</p>\n\t\t\t<p><strong>Message:</strong> {$data['Message']}</p>\n\t\t";
     $email->setBody($messageBody);
     $email->send();
     /*		return array(
     			'Content' => '<p>Thank you for your feedback.</p>',
     			'Form' => ''
     		);
     */
     $this->redirect($_SERVER['HTTP_REFERER'] . "?status=success");
 }
 /**
  * Send a notification directly to a single user
  *
  * @param SystemNotification $notification
  * @param string $email
  * @param array $data
  */
 public function sendToUser($notification, $context, $user, $data)
 {
     $subject = $notification->format($notification->Title, $context, $user, $data);
     if (Config::inst()->get('SystemNotification', 'html_notifications')) {
         $message = $notification->format($notification->NotificationContent(), $context, $user, $data);
     } else {
         $message = $notification->format(nl2br($notification->NotificationContent()), $context, $user, $data);
     }
     if ($template = $notification->getTemplate()) {
         $templateData = $notification->getTemplateData($context, $user, $data);
         $templateData->setField('Body', $message);
         try {
             $body = $templateData->renderWith($template);
         } catch (Exception $e) {
             $body = $message;
         }
     } else {
         $body = $message;
     }
     $from = $this->config()->get('send_notifications_from');
     $to = $user->Email;
     if (!$to && method_exists($user, 'getEmailAddress')) {
         $to = $user->getEmailAddress();
     }
     // log
     $message = "Sending {$subject} to {$to}";
     SS_Log::log($message, SS_Log::NOTICE);
     // send
     $email = new Email($from, $to, $subject);
     $email->setBody($body);
     $this->extend('onBeforeSendToUser', $email);
     $email->send();
 }
 public static function SendAutoResponder($subject = false, $body = false, $EmailFormTo = false)
 {
     $arr_path = explode(".", $_SERVER['HTTP_HOST']);
     $email = new Email("forms@" . $arr_path[1] . "." . $arr_path[2], $EmailFormTo, $subject);
     $email_body = "<html><body>";
     $email_body .= $body;
     $email_body .= "</body></html>";
     $email->setBody($email_body);
     $email->send();
 }
 function sendEmail($data, $form)
 {
     $email = new Email();
     $email->setTo($data['Email']);
     $email->setFrom($data['Email']);
     $email->setSubject('A subject with some umlauts: öäüß');
     $email->setBody('A body with some umlauts: öäüß');
     $email->send();
     echo "<p>email sent to " . $data['Email'] . "</p>";
 }
 public function sendPushNotification(PushNotification $notification)
 {
     $email = new Email();
     $email->setFrom($this->getSetting('From'));
     $email->setSubject($this->getSetting('Subject'));
     $email->setBody($notification->Content);
     foreach ($notification->getRecipients() as $recipient) {
         $email->setTo($recipient->Email);
         $email->send();
     }
 }
Exemple #6
0
 public function submit($data, $form)
 {
     $email = new Email();
     $email->setTo('*****@*****.**');
     $email->setFrom($data['Email']);
     $email->setSubject("Contact Message from {$data["Name"]}");
     $messageBody = " \n            <p><strong>Name:</strong> {$data['Name']}</p> \n            <p><strong>Message:</strong> {$data['Message']}</p> \n        ";
     $email->setBody($messageBody);
     $email->send();
     return array('Content' => '<p>Thank you for your feedback.</p>', 'Form' => '');
 }
Exemple #7
0
 public function sendEmail($data, Form $form)
 {
     $email = new Email();
     $email->setTo('*****@*****.**');
     $email->setFrom($data['Email']);
     $email->setSubject("Contact Message from {$data["Name"]}");
     $messageBody = "\n            <p><strong>Name:</strong> {$data['Name']}</p>\n            <p><strong>Email:</strong> {$data['Email']}</p>\n            <p><strong>Phone:</strong> {$data['Phone']}</p>\n            <p><strong>School:</strong> {$data['School']}</p>\n            <p><strong>Module:</strong> {$data['Module']}</p>\n            <p><strong>Message:</strong> {$data['Message']}</p>\n            ";
     $email->setBody($messageBody);
     $email->send();
     return array('Content' => '<p>Thank you for your feedback.</p>', 'Form' => '');
 }
 public function doContact(array $data)
 {
     $email = new Email();
     $email->setTo(Email::getAdminEmail());
     $email->setFrom($data['Email']);
     $email->setSubject(_t('ContactForm.SUBJECT', 'ContactForm.SUBJECT') . $data['Name']);
     $email->setBody($data['Message']);
     //$email->set
     $email->send();
     $this->sessionMessage(_t('ContactForm.SUCCESS', 'ContactForm.SUCCESS'), 'good');
     $this->controller->redirectBack();
 }
Exemple #9
0
 protected function main()
 {
     $o = $this->mailerQueue->getNext("lock_" . $this->pid);
     if (!$o) {
         return 5000000;
     }
     $email = new Email($o->from, $o->to, $o->subject, null, null);
     $email->setHeaders($o->headers);
     $email->setBody($o->body);
     Mailer::smtp($email);
     $this->mailerQueue->markSent($o->id);
     return 0;
 }
 public function execute(WorkflowInstance $workflow)
 {
     $members = $workflow->getAssignedMembers();
     if (!$members || !count($members)) {
         return true;
     }
     $member = Member::currentUser();
     $initiator = $workflow->Initiator();
     $contextFields = $this->getContextFields($workflow->getTarget());
     $memberFields = $this->getMemberFields($member);
     $initiatorFields = $this->getMemberFields($initiator);
     $variables = array();
     foreach ($contextFields as $field => $val) {
         $variables["\$Context.{$field}"] = $val;
     }
     foreach ($memberFields as $field => $val) {
         $variables["\$Member.{$field}"] = $val;
     }
     foreach ($initiatorFields as $field => $val) {
         $variables["\$Initiator.{$field}"] = $val;
     }
     $pastActions = $workflow->Actions()->sort('Created DESC');
     $variables["\$CommentHistory"] = $this->customise(array('PastActions' => $pastActions, 'Now' => SS_Datetime::now()))->renderWith('CommentHistory');
     $from = str_replace(array_keys($variables), array_values($variables), $this->EmailFrom);
     $subject = str_replace(array_keys($variables), array_values($variables), $this->EmailSubject);
     if ($this->config()->whitelist_template_variables) {
         $item = new ArrayData(array('Initiator' => new ArrayData($initiatorFields), 'Member' => new ArrayData($memberFields), 'Context' => new ArrayData($contextFields), 'CommentHistory' => $variables["\$CommentHistory"]));
     } else {
         $item = $workflow->customise(array('Items' => $workflow->Actions(), 'Member' => $member, 'Context' => new ArrayData($contextFields), 'CommentHistory' => $variables["\$CommentHistory"]));
     }
     if ($this->ListingTemplateID) {
         $template = DataObject::get_by_id('ListingTemplate', $this->ListingTemplateID);
         $view = SSViewer::fromString($template->ItemTemplate);
     } else {
         $view = SSViewer::fromString($this->EmailTemplate);
     }
     $body = $view->process($item);
     foreach ($members as $member) {
         if ($member->Email) {
             $email = new Email();
             $email->setTo($member->Email);
             $email->setSubject($subject);
             $email->setFrom($from);
             $email->setBody($body);
             $email->send();
         }
     }
     return true;
 }
Exemple #11
0
 /**
  * Tests possible sending errors.
  */
 public function testSendErrors()
 {
     $email = new Email();
     $email->setBody(new Email\Body(''));
     $sender = new Sender();
     $sender->setEmail($email);
     // Non-existent sending method
     try {
         $sender->send('dummy-mode');
         $this->fail(sprintf('Expected exception %s.', \InvalidArgumentException::class));
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf(\InvalidArgumentException::class, $e);
     }
     // Missing sender
     try {
         $sender->send(Sender::MODE_NONE);
         $this->fail(sprintf('Expected exception %s.', \Jyxo\Mail\Sender\CreateException::class));
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf(\Jyxo\Mail\Sender\CreateException::class, $e);
     }
     $email->setFrom(new Email\Address('*****@*****.**'));
     // Missing recipients
     try {
         $sender->send(Sender::MODE_NONE);
         $this->fail(sprintf('Expected exception %s.', \Jyxo\Mail\Sender\CreateException::class));
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf(\Jyxo\Mail\Sender\CreateException::class, $e);
     }
     $email->addTo(new Email\Address('*****@*****.**'));
     // Empty body
     try {
         $sender->send(Sender::MODE_NONE);
         $this->fail(sprintf('Expected exception %s.', \Jyxo\Mail\Sender\CreateException::class));
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf(\Jyxo\Mail\Sender\CreateException::class, $e);
     }
 }
 /**
  * Send an email to the email address set in
  * this writer.
  */
 public function _write($event)
 {
     // If no formatter set up, use the default
     if (!$this->_formatter) {
         $formatter = new SS_LogErrorEmailFormatter();
         $this->setFormatter($formatter);
     }
     $formattedData = $this->_formatter->format($event);
     $subject = $formattedData['subject'];
     $data = $formattedData['data'];
     $email = new Email();
     $email->setTo($this->emailAddress);
     $email->setSubject($subject);
     $email->setBody($data);
     $email->setFrom(self::$send_from);
     $email->send();
 }
 /**
  * Email the welcome message and return to the view account page
  */
 function send_email()
 {
     // Construct an Email
     $email = new Email();
     $email->setFrom($this->conf['company']['email'], $this->conf['company']['name']);
     $email->addRecipient($this->session['welcome_email']['email']);
     $email->setSubject($this->session['welcome_email']['subject']);
     $email->setBody($this->session['welcome_email']['email_body']);
     // Send the email
     if (!$email->send()) {
         // Error delivering invoice
         throw new SWUserException("[WELCOME_EMAIL_FAILED]");
     }
     // Return to view_account with a sucess message
     $this->setMessage(array("type" => "[WELCOME_SENT]"));
     $this->gotoPage("accounts_view_account", null, "account=" . $this->get['account']->getID());
 }
Exemple #14
0
 function sendAjax()
 {
     $response = array();
     $comment = $this->input->post('comment');
     $email_address = $this->input->post('email');
     $name = $this->input->post('name');
     $type = $this->input->post('report_type');
     $message = $comment . "\n\n\n";
     foreach ($_SERVER as $k => $v) {
         $message .= $k . ': ' . $v . "\n";
     }
     require_once APPPATH . 'models/objects/email.php';
     $email = new Email();
     $email->setFrom($name . " <{$email_address}>");
     $email->setSubject('readbo.com - Reporting ' . $type . ' - ' . $name);
     $email->setBody($message);
     $response['success'] = $email->send('*****@*****.**');
     $this->sendToAjax($response);
 }
 public function execute(WorkflowInstance $workflow)
 {
     $email = new Email();
     $members = $workflow->getAssignedMembers();
     $emails = '';
     if (!$members || !count($members)) {
         return;
     }
     foreach ($members as $member) {
         if ($member->Email) {
             $emails .= "{$member->Email}, ";
         }
     }
     $context = $this->getContextFields($workflow->getTarget());
     $member = $this->getMemberFields();
     $variables = array();
     foreach ($context as $field => $val) {
         $variables["\$Context.{$field}"] = $val;
     }
     foreach ($member as $field => $val) {
         $variables["\$Member.{$field}"] = $val;
     }
     $subject = str_replace(array_keys($variables), array_values($variables), $this->EmailSubject);
     if ($this->ListingTemplateID) {
         $item = $workflow->customise(array('Items' => $workflow->Actions(), 'Member' => Member::currentUser(), 'Context' => $workflow->getTarget()));
         $template = DataObject::get_by_id('ListingTemplate', $this->ListingTemplateID);
         $view = SSViewer::fromString($template->ItemTemplate);
         $body = $view->process($item);
     } else {
         $body = str_replace(array_keys($variables), array_values($variables), $this->EmailTemplate);
     }
     $email->setSubject($subject);
     $email->setFrom($this->EmailFrom);
     $email->setBcc(substr($emails, 0, -2));
     $email->setBody($body);
     $email->send();
     return true;
 }
    public function send($data, $form)
    {
        $registration = new Registration();
        $form->saveInto($registration);
        $event = $this->getEvent();
        if ($event) {
            $registration->EventID = $event->ID;
            $registration->write();
        }
        // Send an email
        if ($event) {
            $email = new Email('*****@*****.**', $data['Email'], 'Registration received for ' . $event->Title);
            $body = '<p>Hi ' . $data['FirstName'] . ',</p>
<p>We\'ve just received the following registration from you:
<ul>
<li><strong>Name:</strong> ' . $data['FirstName'] . ' ' . $data['LastName'] . '</li>
';
            if (isset($data['Telephone'])) {
                $body .= '<li><strong>Telephone:</strong> ' . $data['Telephone'] . '</li>
';
            }
            $body .= '<li><strong>Event:</strong> ' . $event->Title . '</li>
';
            if (isset($data['SystemID'])) {
                $system = System::get_by_id('System', $data['SystemID']);
                if ($system) {
                    $body .= '<li><strong>Competition:</strong> ' . $system->Title . '</li>';
                }
            }
            $body .= '</ul></p>';
            $body .= $this->RegistrationMessage;
            $email->setBody($body);
            $email->setCC($this->RegistrarEmailAddress);
            $email->send();
        }
        // redirect to the thanks action.
        return $this->redirect('thanks');
    }
 public function process()
 {
     $service = singleton('QueuedJobService');
     $report = $this->getReport();
     if (!$report) {
         $this->currentStep++;
         $this->isComplete = true;
         return;
     }
     $clone = clone $report;
     $clone->GeneratedReportTitle = $report->ScheduledTitle;
     $result = $clone->prepareAndGenerate();
     if ($report->ScheduleEvery) {
         if ($report->ScheduleEvery == 'Custom') {
             $interval = $report->ScheduleEveryCustom;
         } else {
             $interval = $report->ScheduleEvery;
         }
         $next = $service->queueJob(new ScheduledReportJob($report, $this->timesGenerated + 1), date('Y-m-d H:i:s', strtotime("+1 {$interval}")));
         $report->QueuedJobID = $next;
     } else {
         $report->Scheduled = false;
         $report->QueuedJobID = 0;
     }
     $report->write();
     if ($report->EmailScheduledTo) {
         $email = new Email();
         $email->setTo($report->EmailScheduledTo);
         $email->setSubject($result->Title);
         $email->setBody(_t('ScheduledReportJob.SEE_ATTACHED_REPORT', 'Please see the attached report file'));
         $email->attachFile($result->PDFFile()->getFullPath(), $result->PDFFile()->Filename, 'application/pdf');
         $email->send();
     }
     $this->currentStep++;
     $this->isComplete = true;
 }
 public function submit($data, $form)
 {
     $config = SiteConfig::current_site_config();
     $site_email_address = $config->EmailAddress;
     if (empty($site_email_address)) {
         $site_email_address = "*****@*****.**";
     }
     $email = new Email();
     $email->setTo($site_email_address);
     $email->setFrom($data['Email']);
     $email->setSubject("Contact Message from {$data["Name"]}");
     unset($data['url']);
     unset($data['SecurityID']);
     unset($data['action_submit']);
     $messageBody = "";
     foreach ($data as $key => $value) {
         if (!empty($value)) {
             $messageBody = $messageBody . "<p><strong>" . $key . "</strong> " . $value . "</p>";
         }
     }
     $email->setBody($messageBody);
     // $email->send();
     return array('Content' => '<p>Thank you for your feedback.</p>', 'Form' => '');
 }
Exemple #19
0
         * Send out email notifications to reviewers
         */
        $file_obj = new FileData($id, $GLOBALS['connection'], DB_NAME);
        $get_full_name = $user_obj->getFullName();
        $full_name = $get_full_name[0] . ' ' . $get_full_name[1];
        $department = $file_obj->getDepartment();
        $reviewer_obj = new Reviewer($id, $GLOBALS['connection'], DB_NAME);
        $reviewer_list = $reviewer_obj->getReviewersForDepartment($department);
        $date = date('Y-m-d H:i:s T');
        // Build email for general notices
        $mail_subject = msg('checkinpage_file_was_checked_in');
        $mail_body2 = msg('checkinpage_file_was_checked_in') . "\n\n";
        $mail_body2 .= msg('label_filename') . ':  ' . $file_obj->getName() . "\n\n";
        $mail_body2 .= msg('label_status') . ': ' . msg('addpage_new') . "\n\n";
        $mail_body2 .= msg('date') . ': ' . $date . "\n\n";
        $mail_body2 .= msg('addpage_uploader') . ': ' . $full_name . "\n\n";
        $mail_body2 .= msg('email_thank_you') . ',' . "\n\n";
        $mail_body2 .= msg('email_automated_document_messenger') . "\n\n";
        $mail_body2 .= $GLOBALS['CONFIG']['base_url'] . "\n\n";
        $email_obj = new Email();
        $email_obj->setFullName($full_name);
        $email_obj->setSubject($mail_subject);
        $email_obj->setFrom($full_name . ' <' . $user_obj->getEmailAddress() . '>');
        $email_obj->setRecipients($reviewer_list);
        $email_obj->setBody($mail_body2);
        $email_obj->sendEmail();
        // clean up and back to main page
        $last_message = msg('message_document_checked_in');
        header('Location: out.php?last_message=' . urlencode($last_message));
    }
}
Exemple #20
0
 function triggerErrorEmail($message)
 {
     //if job is running and we are trying to start it too, quitting, emailing support
     require_once APPPATH . 'models/objects/email.php';
     $email = new Email();
     $email->setFrom('*****@*****.**');
     $email->setSubject('cron error');
     $email->setBody($message);
     $response = $email->send('*****@*****.**');
     exit;
 }
 public function process()
 {
     $fromTime = $this->since ? $this->since : 0;
     $members = $this->members;
     $nextId = array_shift($members);
     $this->members = $members;
     $member = Member::get()->byID($nextId);
     $microBlogService = $this->microBlogService;
     // if we don't have a 'since' time, we need to only scan from 'now' onwards, to prevent _every_
     // post from being collected
     if (!$fromTime) {
         $fromTime = time();
     }
     $since = date('Y-m-d 00:00:00', $fromTime);
     if ($member && $member->ID) {
         $this->transactionManager->run(function () use($microBlogService, $since, $member) {
             $posts = $microBlogService->globalFeed(array('ParentID' => 0, 'ThreadOwnerID:not' => $member->ID, 'Created:GreaterThan' => $since), $orderBy = 'ID DESC', $since = null, $number = 10, $markViewed = false);
             if (!count($posts)) {
                 return;
             }
             $content = SSViewer::execute_template('DigestEmail', ArrayData::create(array('Posts' => $posts, 'Member' => $member)));
             $content = HTTP::absoluteURLs($content);
             $config = SiteConfig::current_site_config();
             $mail = new Email();
             $mail->setTo($member->Email);
             $mail->setBody($content);
             $mail->setSubject($config->Title . ' digest');
             if ($config->FromEmail) {
                 $mail->setFrom($config->FromEmail);
             }
             $mail->send();
         }, $member);
     }
     $this->currentStep++;
     if (count($members) == 0) {
         if (!$this->sendTime) {
             $this->sendTime = '23:55:00';
         }
         $nextTime = $this->type == 'weekly' ? '+1 week' : '+1 day';
         $nextDate = date('Y-m-d ' . $this->sendTime, strtotime($nextTime));
         $nextJob = new MicroPostDigestJob(time(), $this->type, $this->groupId, $this->sendTime);
         singleton('QueuedJobService')->queueJob($nextJob, $nextDate);
         $this->isComplete = true;
     }
 }
 private function email_alert()
 {
     if ($this->error_recently_sent()) {
         //return;	//error already emailed recently
     }
     if (!Config::isLive()) {
         error_log("Email alert would have been sent for this error.");
         global $argv;
         if (isset($argv[1])) {
             $this->alert_emails = array($argv[1]);
         } else {
             return;
             //do not send emails for testing
         }
     }
     $error_level = $this->exception->getSeverity();
     $subject = "PHP Error[" . $error_level . "] : " . $this->exception->getFile();
     $body = "";
     $body .= "\n Error sent from /utility/ErrorHandler.class";
     $body .= "\n PHP Error #: " . $error_level;
     $body .= "\n Error Message: " . $this->exception->getMessage();
     $body .= "\n File: " . $this->exception->getFile();
     $body .= "\n Line: " . $this->exception->getLine();
     $body .= "\n DateTime: " . date("Y-m-d H:i:s");
     if (isset($_SERVER['REMOTE_ADDR'])) {
         $body .= "\n Remote Address: " . $_SERVER['REMOTE_ADDR'];
     }
     if (isset($_SERVER['SERVER_ADDR'])) {
         $body .= "\n Server Address: " . $_SERVER['SERVER_ADDR'];
     }
     if (isset($_SERVER['SERVER_NAME'])) {
         $body .= "\n Server Name: " . $_SERVER['SERVER_NAME'];
     }
     $body .= "\n Trace: " . $this->exception->getTraceAsString();
     Loader::load('utility', "email/Email");
     $email = new Email();
     $email->setBody($body);
     $email->setSubject($subject);
     $email->setFromAddress("Error Alert", "");
     $email->addToAddress("Debugging", "*****@*****.**");
     $email->sendAsPlainText();
     $email->send();
 }
Exemple #23
0
 public static function sendText($to, $subject, $msg, $anexos = array())
 {
     $email = new Email();
     $email->to = $to;
     $email->subject = $subject;
     $email->format = 'text';
     $email->setBody($msg);
     $email->anexos = $anexos;
     $email->message->embed = false;
     $email->sendMail();
 }
 /**
  * Constructs an email object for the given order (if possible)
  * @param Order $order
  * @return Email|null
  */
 public function getEmailForOrder(Order $order)
 {
     $data = CustomerDataExtractor::inst()->extract($order);
     $emailAddress = $data['Email'];
     // Send to admin?
     if ($this->To === self::TO_ADMIN) {
         $emailAddress = FollowUpEmail::config()->admin_email;
         if (empty($emailAddress)) {
             $emailAddress = Email::config()->admin_email;
         }
     }
     // Send the email if possible
     if (!empty($emailAddress)) {
         // fill in some additional templating
         $data = $this->performSubstitutions($data, $order);
         // build the email
         $email = new Email();
         $email->setFrom(Email::config()->admin_email);
         $email->setTo($emailAddress);
         $email->setSubject($this->Subject);
         $body = $this->customise($data)->renderWith(array('FollowUpEmail'));
         foreach ($data as $k => $v) {
             $body = str_replace(array('http://{{{' . $k . '}}}', '{{{' . $k . '}}}'), array($v, $v), $body);
         }
         $email->setBody($body);
         return $email;
     } else {
         return null;
     }
 }
Exemple #25
0
 public function RequestInvoice()
 {
     $this->RegisterForEventByInvoice();
     $member = Member::currentUser()->Email;
     $email = new Email();
     $email->setTo('*****@*****.**');
     $email->setFrom($member);
     $email->setSubject("Invoice Request");
     $messageBody = "";
     $messageBody = "Member " . $member . " (" . Member::currentUser()->FirstName . " " . Member::currentUser()->LastName . ")";
     $messageBody .= " has requested an invoice for the event '" . $this->myEventName . "'.";
     $email->setBody($messageBody);
     $email->send(Member::currentUser()->Email);
     return true;
 }
</head>

<body>
<?php 
include "Email.php";
//Caso os arquivos sejam vários arquivos
set_time_limit(0);
if (isset($_POST["send"])) {
    extract($_POST);
    $email = new Email();
    $email->setAttachment($_FILES["arquivo"]);
    $email->setSender($remetente);
    $email->setDestiny($destinatario);
    $email->setCopy($copia);
    $email->setSubject($assunto);
    $email->setBody($mensagem);
    $check = $email->send();
    if ($check) {
        echo "<script>alert('Email enviado com Sucesso!');</script>";
    } else {
        echo "<script>alert('Houve um erro ao processar seu pedido!');</script>";
    }
}
?>
<h3>Thiago Paz  - www.programador.me </h3>
<a href="https://github.com/ThiagoVieiraPaz/" target="new"><img src="http://programador.me/public/images/bt_git.png"></a>
<h1>Enviar email com Anexo!</h1>
<hr>
<div class="col-md-5">
<form action="" method="post" enctype="multipart/form-data">
 <div class="form-group">
 /** man_exception::_sendOutEmail()
  * send out the email to developers@manlinegroup.com
  * @return true on success false otherwise
  */
 private function _sendOutEmail()
 {
     require_once BASE . 'basefunctions/baseapis/communications/Email.class.php';
     $email = new Email();
     $email->setTo(array('Manline Developers' => '*****@*****.**'));
     $email->setSubject('Exception: ' . $this->string);
     $email->setBody($this->_html);
     if ($email->send() === false) {
         return false;
     }
     return true;
 }
Exemple #28
0
 /**
  * Runs the test.
  */
 public function test()
 {
     $filePath = DIR_FILES . '/mail';
     $subject = 'Novinky září 2009 ... a kreslící soutěž';
     $from = new Email\Address('*****@*****.**', 'Blog.cz');
     $to = array(new Email\Address('*****@*****.**', 'Test Test1'), new Email\Address('*****@*****.**'));
     $cc = array(new Email\Address('*****@*****.**', 'Test Test3'), new Email\Address('*****@*****.**'));
     $bcc = array(new Email\Address('*****@*****.**', 'Test Test5'));
     $headers = array(new Email\Header('Organization', 'Blog.cz'));
     $inReplyTo = '*****@*****.**';
     $references = array('*****@*****.**', '*****@*****.**');
     $html = file_get_contents($filePath . '/email.html');
     $body = new Email\Body($html, \Jyxo\Html::toText($html));
     $attachments = array(new Email\Attachment\File($filePath . '/logo.gif', 'logo.gif', 'image/gif'), new Email\Attachment\String(file_get_contents($filePath . '/star.gif'), 'star.gif', 'image/gif'));
     $inlineAttachments = array(new Email\Attachment\InlineFile($filePath . '/logo.gif', 'logo.gif', 'logo.gif', 'image/gif'), new Email\Attachment\InlineString(file_get_contents($filePath . '/star.gif'), 'star.gif', 'star.gif', 'image/gif'));
     // Basic settings
     $email = new Email();
     $email->setSubject($subject)->setFrom($from)->addReplyTo($from)->setInReplyTo($inReplyTo, $references)->setConfirmReadingTo($from);
     $this->assertEquals($subject, $email->getSubject());
     $this->assertSame($from, $email->getFrom());
     $this->assertSame(array($from), $email->getReplyTo());
     $this->assertSame($from, $email->getConfirmReadingTo());
     $this->assertEquals($inReplyTo, $email->getInReplyTo());
     $this->assertSame($references, $email->getReferences());
     // Recipients
     foreach ($to as $address) {
         $email->addTo($address);
     }
     foreach ($cc as $address) {
         $email->addCc($address);
     }
     foreach ($bcc as $address) {
         $email->addBcc($address);
     }
     $this->assertSame($to, $email->getTo());
     $this->assertSame($cc, $email->getCc());
     $this->assertSame($bcc, $email->getBcc());
     // Priority
     $reflection = new \ReflectionClass('\\Jyxo\\Mail\\Email');
     foreach ($reflection->getConstants() as $name => $value) {
         if (0 === strpos($name, 'PRIORITY_')) {
             $email->setPriority($value);
             $this->assertEquals($value, $email->getPriority());
         }
     }
     try {
         $email->setPriority('dummy-priority');
         $this->fail('Expected exception \\InvalidArgumentException.');
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf('\\InvalidArgumentException', $e);
     }
     // Headers
     foreach ($headers as $header) {
         $email->addHeader($header);
     }
     $this->assertSame($headers, $email->getHeaders());
     // Body
     $email->setBody($body);
     $this->assertSame($body, $email->getBody());
     // Attachments
     foreach ($attachments as $attachment) {
         $email->addAttachment($attachment);
     }
     $this->assertSame($attachments, $email->getAttachments());
     $this->assertFalse($email->hasInlineAttachments());
     foreach ($inlineAttachments as $attachment) {
         $email->addAttachment($attachment);
     }
     $this->assertSame(array_merge($attachments, $inlineAttachments), $email->getAttachments());
     $this->assertTrue($email->hasInlineAttachments());
 }
Exemple #29
0
function createMyCapsAppoint($userdetails, $reminder)
{
    // Sender  details {
    $from_name = "MyCaps System";
    $from_address = "*****@*****.**";
    // }
    // Convert MYSQL datetime and construct iCal start, end and issue dates {
    $dtstart = gmdate("Ymd\\T110000\\Z", $reminder["duedate"]);
    $dtend = gmdate("Ymd\\T120000\\Z", $reminder["duedate"]);
    $todaystamp = gmdate("Ymd\\T110000\\Z");
    // }
    //Create Mime Boundry
    $mime_boundary = "----Meeting Booking----" . md5(time());
    // Letter details and Email headers {
    $subject = "Deadline for task " . $reminder["desc"];
    //Doubles as email subject and meeting subject in calendar
    $meeting_description = "Here is a brief description of my meeting\n\n";
    $meeting_location = "My Office";
    //Where will your meeting take place
    $headers = "From: " . $from_name . " <" . $from_address . ">\n";
    //$headers .= "Reply-To: ".$from_name." <".$from_address.">\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/alternative; boundary=\"{$mime_boundary}\"\n";
    $headers .= "Content-class: urn:content-classes:calendarmessage\n";
    // }
    //Create Email Body (HTML) {
    $message .= "--{$mime_boundary}\n";
    $message .= "Content-Type: text/html; charset=UTF-8\n";
    $message .= "Content-Transfer-Encoding: 8bit\n\n";
    $message .= "<html>\n";
    $message .= "<body>\n";
    $message .= '<p>Dear ' . $userdetails["firstname"] . ' ' . $userdetails["lastname"] . ',</p>';
    $message .= '<p>Would you like to add a calender event for your MyCaps task?</p>';
    $message .= "<p>The due date for this task is " . date("d M Y", $reminder["duedate"]) . "</p>";
    $message .= "</body>\n";
    $message .= "</html>\n";
    $message .= "--{$mime_boundary}\n";
    // }
    $ical = "BEGIN:VCALENDAR\n";
    $ical .= "PRODID:Zimbra-Calendar-Provider\n";
    $ical .= "VERSION:2.0\n";
    $ical .= "METHOD:REQUEST\n";
    $ical .= "BEGIN:VEVENT\n";
    $ical .= "UID:MANLINE" . date("U") . "\n";
    $ical .= "SUMMARY:Deadline for " . $reminder["desc"] . "\n";
    $ical .= "LOCATION:PC\n";
    $ical .= "ORGANIZER;CN=" . $userdetails["firstname"] . " " . $userdetails["lastname"] . ";ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=FALSE\n";
    $ical .= ":mailto:" . $userdetails["email"] . "\n";
    $ical .= "DTSTART:" . $dtstart . "\n";
    $ical .= "DTEND:" . $dtend . "\n";
    $ical .= "STATUS:CONFIRMED\n";
    $ical .= "CLASS:PUBLIC\n";
    $ical .= "X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY\n";
    $ical .= "TRANSP:OPAQUE\n";
    $ical .= "X-MICROSOFT-DISALLOW-COUNTER:TRUE\n";
    $ical .= "DTSTAMP:" . date("Ymd\\Thms\\Z") . "\n";
    $ical .= "SEQUENCE:0\n";
    $ical .= "DESCRIPTION: BLAH\n";
    $ical .= "BEGIN:VALARM\n";
    $ical .= "ACTION:DISPLAY\n";
    $ical .= "TRIGGER;RELATED=START:-PT5M\n";
    $ical .= "DESCRIPTION:Reminder\n";
    $ical .= "END:VALARM\n";
    $ical .= "END:VEVENT\n";
    $ical .= "END:VCALENDAR";
    $message .= "Content-Type: text/calendar;name='meeting.ics';method=REQUEST\n";
    $message .= "Content-Transfer-Encoding: 8bit\n\n";
    $message .= $ical;
    //SEND MAIL
    require_once BASE . "basefunctions/baseapis/communications/Email.class.php";
    $email = new Email();
    $email->setBody($message, true);
    $email->setHeaders($headers);
    $email->setTo(str_replace("\"'", "", $userdetails["email"]));
    $email->setSubject($subject);
    if ($email->send() === false) {
        return false;
    }
    return true;
}
 function notifyChanges($changes)
 {
     $email = new Email(Email::getAdminEmail(), Email::getAdminEmail(), 'Changed Fields');
     $body = "";
     foreach ($changes as $change) {
         $body .= "-------------------------------\n";
         $body .= implode(' ', $change) . "\n";
     }
     $email->setBody($body);
     $email->send();
 }