summaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
authorSimon Rettberg2023-05-12 14:23:59 +0200
committerSimon Rettberg2023-05-12 14:23:59 +0200
commitc626b0f08fba3ad8c70ad32c7d97d9938797a420 (patch)
tree2118ef965298d02c84bcbf49be518cf3ebcc7724 /inc
parent[locations] cleanup: Hide/disable move button if action not available (diff)
downloadslx-admin-c626b0f08fba3ad8c70ad32c7d97d9938797a420.tar.gz
slx-admin-c626b0f08fba3ad8c70ad32c7d97d9938797a420.tar.xz
slx-admin-c626b0f08fba3ad8c70ad32c7d97d9938797a420.zip
[inc/Mailer] Allow Somename <some@example.com> format as FROM
Diffstat (limited to 'inc')
-rw-r--r--inc/mailer.inc.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/inc/mailer.inc.php b/inc/mailer.inc.php
index 942bfc75..05b6a08c 100644
--- a/inc/mailer.inc.php
+++ b/inc/mailer.inc.php
@@ -15,9 +15,16 @@ class Mailer
/** @var string */
private $errlog = '';
+ /** @var string */
+ private $from;
+
// $keys = array('host', 'port', 'ssl', 'senderAddress', 'replyTo', 'username', 'password', 'serverName');
public function __construct(string $hosturi, bool $startTls, string $from, string $user, string $pass, string $replyTo = null)
{
+ $this->from = $from;
+ if (preg_match('/[^<>"\'\s]+@[^<>"\'\s]+/i', $from, $out)) {
+ $from = $out[0];
+ }
$this->curlOptions = [
CURLOPT_URL => $hosturi,
CURLOPT_USE_SSL => $startTls ? CURLUSESSL_ALL : CURLUSESSL_TRY,
@@ -53,7 +60,7 @@ class Mailer
}
$mail[] = self::mimeEncode('Content-Type', 'text/plain; charset="utf-8"');
$mail[] = self::mimeEncode('Subject', $subject);
- $mail[] = self::mimeEncode('From', $this->curlOptions[CURLOPT_MAIL_FROM]);
+ $mail[] = self::mimeEncode('From', $this->from);
$mail[] = self::mimeEncode('Message-ID', '<' . Util::randomUuid() . '@rfcpedant.example.org>');
if (!empty($this->replyTo)) {
$mail[] = self::mimeEncode('Reply-To', $this->replyTo);