ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
MandrillHandler.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Monolog\Handler;
13
15
22{
23 protected $client;
24 protected $message;
25
32 public function __construct($apiKey, $message, $level = Logger::ERROR, $bubble = true)
33 {
34 parent::__construct($level, $bubble);
35
36 if (!$message instanceof \Swift_Message && is_callable($message)) {
37 $message = call_user_func($message);
38 }
39 if (!$message instanceof \Swift_Message) {
40 throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it');
41 }
42 $this->message = $message;
43 $this->apiKey = $apiKey;
44 }
45
49 protected function send($content, array $records)
50 {
52 $message->setBody($content);
53 $message->setDate(time());
54
55 $ch = curl_init();
56
57 curl_setopt($ch, CURLOPT_URL, 'https://mandrillapp.com/api/1.0/messages/send-raw.json');
58 curl_setopt($ch, CURLOPT_POST, 1);
59 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
60 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
61 'key' => $this->apiKey,
62 'raw_message' => (string) $message,
63 'async' => false,
64 )));
65
67 }
68}
static execute($ch, $retries=5, $closeAfterDone=true)
Executes a CURL request with optional retries and exception on failure.
Definition: Util.php:32
Base class for all mail handlers.
Definition: MailHandler.php:20
MandrillHandler uses cURL to send the emails to the Mandrill API.
send($content, array $records)
{Send a mail with the given content.}
__construct($apiKey, $message, $level=Logger::ERROR, $bubble=true)
Monolog log channel.
Definition: Logger.php:28
const ERROR
Runtime errors.
Definition: Logger.php:57
$records
Definition: simple_test.php:17