本文整理汇总了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;
}