本文整理匯總了PHP中Mailgun\Mailgun::MessageBuilder方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mailgun::MessageBuilder方法的具體用法?PHP Mailgun::MessageBuilder怎麽用?PHP Mailgun::MessageBuilder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mailgun\Mailgun
的用法示例。
在下文中一共展示了Mailgun::MessageBuilder方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: later
/**
* @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);
}
示例2: transportMailMailgun
/**
* 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;
}