diff options
Diffstat (limited to 'app/class/globals.php')
-rw-r--r-- | app/class/globals.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/class/globals.php b/app/class/globals.php index e4285cd..0d4b0ac 100644 --- a/app/class/globals.php +++ b/app/class/globals.php @@ -153,11 +153,19 @@ function saveFile(array $file, string $path, int $maxsize, ?array $allowedMime = * parameters. If config is not established, delivery is * not attempted. Send status (t/f) is returned. */ -function sendEmail(string $subject, string $rcpt, string $mesg) : bool +function sendEmail(string $subject, user $rcpt, string $mesg, + ?string $attachPath = NULL, ?string $attachName = NULL, + bool $overrideEmailConf = false) : bool { if (settings::smtpServer() == "") return false; + if (!$overrideEmailConf && !$rcpt->emailConf) + return true; + + if ($rcpt->email == "") + return true; + $mail = new PHPMailer(); $mail->isSMTP(); $mail->SMTPAuth = true; @@ -168,10 +176,13 @@ function sendEmail(string $subject, string $rcpt, string $mesg) : bool $mail->Port = settings::smtpPort(); $mail->setFrom(settings::smtpEmailAddress()); - $mail->addAddress($rcpt); + $mail->addAddress($rcpt->email, $rcpt->getDisplayName()); $mail->Subject = $subject; $mail->Body = $mesg; + if ($attachPath && $attachName) + $mail->addAttachment($attachPath, $attachName); + return $mail->send(); } |