/** * @param int|array|\DateTime|Carbon $time * @param string|array $view * @param array $data * @param \Closure $callback * * @return \Bogardo\Mailgun\Http\Response */ public function later($time, $view, array $data, Closure $callback) { $message = new Message($this->mailgun->MessageBuilder(), $this->config); $message->builder()->setDeliveryTime($this->parseTime($time), $this->config->get('app.timezone', 'UTC')); return $this->send($view, $data, $callback, $message); }
/** * Transport mail message with mailgun services * * @param $to * @param $subj * @param $body * @param $hash * @param $intro * @param $options * * @return bool */ public static function transportMailMailgun($to, $subj, $body, $hash, $intro, $options) { // @TODO make sure that from and reply-to addresses are correctly set in headers if (!is_array($to)) { $to = explode(',', $to); } $signature = Util::lavnn('signature', $options, 'team'); $language = Util::lavnn('language', $options, 'en'); $sender = Util::lavnn('sender', $options, 0); $config = Config::getInstance(); # Instantiate the client. $mgClient = new Mailgun($config->get('mailgun.apiKey')); $domain = $config->get('mailgun.domain'); $msgBuilder = $mgClient->MessageBuilder(); $from = $config->get('mailgun.from'); if ($signature != 'team' && $sender > 0) { $userModel = new User(); if ($userModel->load($sender)->isValid()) { $from = $userModel->get('fname') . ' ' . $userModel->get('lname') . ' <' . $userModel->get('email') . '>'; } } $msgBuilder->setFromAddress($from); foreach ($to as $recipient) { $msgBuilder->addToRecipient(trim($recipient)); } $msgBuilder->setSubject($subj); $msgBuilder->setTextBody(self::prepareTextMail($subj, $body, $hash, $intro, $signature, $language, $sender)); $msgBuilder->setHtmlBody(self::prepareHtmlMail($subj, $body, $hash, $intro, $signature, $language, $sender)); $result = $mgClient->post("{$domain}/messages", $msgBuilder->getMessage(), $msgBuilder->getFiles()); return $result->http_response_code == 200; }