From c373cfbc307218947fb12d90763aca8746c074ab Mon Sep 17 00:00:00 2001 From: Liam O'Boyle Date: Tue, 3 Mar 2015 11:42:38 +1100 Subject: [PATCH] Allow passing additional parameters to PHP's mail(). PHP's mail() function accepts an optional additional_parameters argument which can be used to provide additional information, such as setting the envelope sender, for some MTAs. This patch allows the NativeMailerHandler to pass these through. --- src/Monolog/Handler/NativeMailerHandler.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Monolog/Handler/NativeMailerHandler.php b/src/Monolog/Handler/NativeMailerHandler.php index b3318f0a..4a5901f3 100644 --- a/src/Monolog/Handler/NativeMailerHandler.php +++ b/src/Monolog/Handler/NativeMailerHandler.php @@ -39,6 +39,12 @@ class NativeMailerHandler extends MailHandler */ protected $headers = array(); + /** + * Optional parameters for the message + * @var array + */ + protected $parameters = array(); + /** * The wordwrap length for the message * @var integer @@ -90,6 +96,19 @@ class NativeMailerHandler extends MailHandler } } + /** + * Add parameters to the message + * + * @param string|array $arguments Custom added parameters + * @return self + */ + public function addParameter($parameters) + { + $this->parameters = array_merge($this->parameters, (array) $parameters); + + return $this; + } + /** * {@inheritdoc} */ @@ -102,7 +121,7 @@ class NativeMailerHandler extends MailHandler $headers .= 'MIME-Version: 1.0' . "\r\n"; } foreach ($this->to as $to) { - mail($to, $this->subject, $content, $headers); + mail($to, $this->subject, $content, $headers, implode(' ', $this->parameters)); } }