ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Monolog\Handler\NativeMailerHandler Class Reference

NativeMailerHandler uses the mail() function to send the emails. More...

+ Inheritance diagram for Monolog\Handler\NativeMailerHandler:
+ Collaboration diagram for Monolog\Handler\NativeMailerHandler:

Public Member Functions

 __construct ($to, $subject, $from, $level=Logger::ERROR, $bubble=true, $maxColumnWidth=70)
 
 addHeader ($headers)
 Add headers to the message. More...
 
 addParameter ($parameters)
 Add parameters to the message. More...
 
 getContentType ()
 
 getEncoding ()
 
 setContentType ($contentType)
 
 setEncoding ($encoding)
 
- Public Member Functions inherited from Monolog\Handler\MailHandler
 handleBatch (array $records)
 {{Handles a set of records at once.
Parameters
array$recordsThe records to handle (an array of record arrays)
}} More...
 
- Public Member Functions inherited from Monolog\Handler\AbstractProcessingHandler
 handle (array $record)
 {Handles a record.All records may be passed to this method, and the handler should discard those that it does not want to handle.The return value of this function controls the bubbling process of the handler stack. Unless the bubbling is interrupted (by returning true), the Logger class will keep on calling further handlers in the stack with a given log record.
Parameters
array$recordThe record to handle
Returns
Boolean true means that this handler handled the record, and that bubbling is not permitted. false means the record was either not processed or that this handler allows bubbling.
} More...
 
- Public Member Functions inherited from Monolog\Handler\AbstractHandler
 __construct ($level=Logger::DEBUG, $bubble=true)
 
 isHandling (array $record)
 {Checks whether the given record will be handled by this handler.This is mostly done for performance reasons, to avoid calling processors for nothing.Handlers should still check the record levels within handle(), returning false in isHandling() is no guarantee that handle() will not be called, and isHandling() might not be called for a given record.
Parameters
array$recordPartial log record containing only a level key
Returns
Boolean
} More...
 
 handleBatch (array $records)
 {Handles a set of records at once.
Parameters
array$recordsThe records to handle (an array of record arrays)
} More...
 
 close ()
 Closes the handler. More...
 
 pushProcessor ($callback)
 {Adds a processor in the stack.
Parameters
callable$callback
Returns
self
} More...
 
 popProcessor ()
 {Removes the processor on top of the stack and returns it.
Returns
callable
} More...
 
 setFormatter (FormatterInterface $formatter)
 {Sets the formatter.
Parameters
FormatterInterface$formatter
Returns
self
} More...
 
 getFormatter ()
 {Gets the formatter.
Returns
FormatterInterface
} More...
 
 setLevel ($level)
 Sets minimum logging level at which this handler will be triggered. More...
 
 getLevel ()
 Gets minimum logging level at which this handler will be triggered. More...
 
 setBubble ($bubble)
 Sets the bubbling behavior. More...
 
 getBubble ()
 Gets the bubbling behavior. More...
 
 __destruct ()
 
 isHandling (array $record)
 Checks whether the given record will be handled by this handler. More...
 
 handle (array $record)
 Handles a record. More...
 
 handleBatch (array $records)
 Handles a set of records at once. More...
 
 pushProcessor ($callback)
 Adds a processor in the stack. More...
 
 popProcessor ()
 Removes the processor on top of the stack and returns it. More...
 
 setFormatter (FormatterInterface $formatter)
 Sets the formatter. More...
 
 getFormatter ()
 Gets the formatter. More...
 

Protected Member Functions

 send ($content, array $records)
 {Send a mail with the given content.
Parameters
string$contentformatted email body to be sent
array$recordsthe array of log records that formed this content
} More...
 
- Protected Member Functions inherited from Monolog\Handler\MailHandler
 send ($content, array $records)
 Send a mail with the given content. More...
 
 write (array $record)
 {Writes the record down to the log of the implementing handler.
Parameters
array$record
Returns
void
} More...
 
- Protected Member Functions inherited from Monolog\Handler\AbstractProcessingHandler
 write (array $record)
 Writes the record down to the log of the implementing handler. More...
 
 processRecord (array $record)
 Processes a record. More...
 
- Protected Member Functions inherited from Monolog\Handler\AbstractHandler
 getDefaultFormatter ()
 Gets the default formatter. More...
 

Protected Attributes

 $to
 
 $subject
 
 $headers = array()
 
 $parameters = array()
 
 $maxColumnWidth
 
 $contentType = 'text/plain'
 
 $encoding = 'utf-8'
 
- Protected Attributes inherited from Monolog\Handler\AbstractHandler
 $level = Logger::DEBUG
 
 $bubble = true
 
 $formatter
 
 $processors = array()
 

Detailed Description

NativeMailerHandler uses the mail() function to send the emails.

Author
Christophe Coevoet stof@.nosp@m.notk.nosp@m..org
Mark Garrett mark@.nosp@m.mode.nosp@m.rndev.nosp@m.elop.nosp@m.erllc.nosp@m..com

Definition at line 22 of file NativeMailerHandler.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Handler\NativeMailerHandler::__construct (   $to,
  $subject,
  $from,
  $level = Logger::ERROR,
  $bubble = true,
  $maxColumnWidth = 70 
)
Parameters
string | array$toThe receiver of the mail
string$subjectThe subject of the mail
string$fromThe sender of the mail
integer$levelThe minimum logging level at which this handler will be triggered
boolean$bubbleWhether the messages that are handled can bubble up the stack or not
int$maxColumnWidthThe maximum column width that the message lines will have

Definition at line 74 of file NativeMailerHandler.php.

75 {
76 parent::__construct($level, $bubble);
77 $this->to = is_array($to) ? $to : array($to);
78 $this->subject = $subject;
79 $this->addHeader(sprintf('From: %s', $from));
80 $this->maxColumnWidth = $maxColumnWidth;
81 }
addHeader($headers)
Add headers to the message.

References Monolog\Handler\AbstractHandler\$bubble, Monolog\Handler\AbstractHandler\$level, Monolog\Handler\NativeMailerHandler\$maxColumnWidth, Monolog\Handler\NativeMailerHandler\$subject, Monolog\Handler\NativeMailerHandler\$to, and Monolog\Handler\NativeMailerHandler\addHeader().

+ Here is the call graph for this function:

Member Function Documentation

◆ addHeader()

Monolog\Handler\NativeMailerHandler::addHeader (   $headers)

Add headers to the message.

Parameters
string | array$headersCustom added headers
Returns
self

Definition at line 89 of file NativeMailerHandler.php.

90 {
91 foreach ((array) $headers as $header) {
92 if (strpos($header, "\n") !== false || strpos($header, "\r") !== false) {
93 throw new \InvalidArgumentException('Headers can not contain newline characters for security reasons');
94 }
95 $this->headers[] = $header;
96 }
97
98 return $this;
99 }
$header

References $header, and Monolog\Handler\NativeMailerHandler\$headers.

Referenced by Monolog\Handler\NativeMailerHandler\__construct().

+ Here is the caller graph for this function:

◆ addParameter()

Monolog\Handler\NativeMailerHandler::addParameter (   $parameters)

Add parameters to the message.

Parameters
string | array$parametersCustom added parameters
Returns
self

Definition at line 107 of file NativeMailerHandler.php.

108 {
109 $this->parameters = array_merge($this->parameters, (array) $parameters);
110
111 return $this;
112 }

References Monolog\Handler\NativeMailerHandler\$parameters.

◆ getContentType()

Monolog\Handler\NativeMailerHandler::getContentType ( )
Returns
string $contentType

Definition at line 133 of file NativeMailerHandler.php.

References Monolog\Handler\NativeMailerHandler\$contentType.

Referenced by Monolog\Handler\NativeMailerHandler\send().

+ Here is the caller graph for this function:

◆ getEncoding()

Monolog\Handler\NativeMailerHandler::getEncoding ( )
Returns
string $encoding

Definition at line 141 of file NativeMailerHandler.php.

References Monolog\Handler\NativeMailerHandler\$encoding.

Referenced by Monolog\Handler\NativeMailerHandler\send().

+ Here is the caller graph for this function:

◆ send()

Monolog\Handler\NativeMailerHandler::send (   $content,
array  $records 
)
protected

{Send a mail with the given content.

Parameters
string$contentformatted email body to be sent
array$recordsthe array of log records that formed this content
}

Reimplemented from Monolog\Handler\MailHandler.

Definition at line 117 of file NativeMailerHandler.php.

118 {
119 $content = wordwrap($content, $this->maxColumnWidth);
120 $headers = ltrim(implode("\r\n", $this->headers) . "\r\n", "\r\n");
121 $headers .= 'Content-type: ' . $this->getContentType() . '; charset=' . $this->getEncoding() . "\r\n";
122 if ($this->getContentType() == 'text/html' && false === strpos($headers, 'MIME-Version:')) {
123 $headers .= 'MIME-Version: 1.0' . "\r\n";
124 }
125 foreach ($this->to as $to) {
126 mail($to, $this->subject, $content, $headers, implode(' ', $this->parameters));
127 }
128 }

References Monolog\Handler\NativeMailerHandler\$headers, Monolog\Handler\NativeMailerHandler\$to, Monolog\Handler\NativeMailerHandler\getContentType(), and Monolog\Handler\NativeMailerHandler\getEncoding().

+ Here is the call graph for this function:

◆ setContentType()

Monolog\Handler\NativeMailerHandler::setContentType (   $contentType)
Parameters
string$contentTypeThe content type of the email - Defaults to text/plain. Use text/html for HTML messages.
Returns
self

Definition at line 151 of file NativeMailerHandler.php.

152 {
153 if (strpos($contentType, "\n") !== false || strpos($contentType, "\r") !== false) {
154 throw new \InvalidArgumentException('The content type can not contain newline characters to prevent email header injection');
155 }
156
157 $this->contentType = $contentType;
158
159 return $this;
160 }

References Monolog\Handler\NativeMailerHandler\$contentType.

◆ setEncoding()

Monolog\Handler\NativeMailerHandler::setEncoding (   $encoding)
Parameters
string$encoding
Returns
self

Definition at line 166 of file NativeMailerHandler.php.

167 {
168 if (strpos($encoding, "\n") !== false || strpos($encoding, "\r") !== false) {
169 throw new \InvalidArgumentException('The encoding can not contain newline characters to prevent email header injection');
170 }
171
172 $this->encoding = $encoding;
173
174 return $this;
175 }

References Monolog\Handler\NativeMailerHandler\$encoding.

Field Documentation

◆ $contentType

Monolog\Handler\NativeMailerHandler::$contentType = 'text/plain'
protected

◆ $encoding

Monolog\Handler\NativeMailerHandler::$encoding = 'utf-8'
protected

◆ $headers

Monolog\Handler\NativeMailerHandler::$headers = array()
protected

◆ $maxColumnWidth

Monolog\Handler\NativeMailerHandler::$maxColumnWidth
protected

◆ $parameters

Monolog\Handler\NativeMailerHandler::$parameters = array()
protected

◆ $subject

Monolog\Handler\NativeMailerHandler::$subject
protected

◆ $to

Monolog\Handler\NativeMailerHandler::$to
protected

The documentation for this class was generated from the following file: