Closed realizelol closed 1 year ago
PHP8.x uses the correct line endings in mail [ "\r\n" (CRLF) ] - There's actually a bug open @ php: https://github.com/php/php-src/issues/8086
I actually using this method - because script that are using: /usr/local/emhttp/webGui/scripts/notify or /usr/local/emhttp/plugins/dynamix/scripts/notify may result in error 554 by mail provider -> e.g. https://postmaster.gmx.net/en/case?c=hi&i=ip :
/usr/local/emhttp/webGui/scripts/notify
/usr/local/emhttp/plugins/dynamix/scripts/notify
function generate_email($event, $subject, $description, $importance, $message, $recipients, $fqdnlink) { $line_break = (PHP_VERSION_ID < 80000) ? "\n" : "\r\n"; global $ssmtp; $rcpt = $ssmtp['RcptTo']; if (!$recipients) $to = implode(',', explode(' ', trim($rcpt))); else $to = $recipients; if (empty($to)) return; $subj = "{$ssmtp['Subject']}$subject"; $headers = []; $headers[] = "MIME-Version: 1.0"; $headers[] = "X-Mailer: PHP/".phpversion(); $headers[] = "Content-type: text/plain; charset=utf-8"; $headers[] = "From: {$ssmtp['root']}"; $headers[] = "Reply-To: {$ssmtp['root']}"; //$headers[] = "Subject: $subject"; if (($importance == "warning" || $importance == "alert") && $ssmtp['SetEmailPriority']=="True") { $headers[] = "X-Priority: 1 (highest)"; $headers[] = "X-Mms-Priority: High"; } $body = []; if (!empty($fqdnlink)) { $body[] = "Link: $fqdnlink"; $body[] = ""; } $body[] = "Event: $event"; $body[] = "OrigSubject: $subject"; $body[] = "Description: $description"; $body[] = "Importance: $importance"; if (!empty($message)) { $body[] = ""; foreach (explode('\n', $message) as $line) $body[] = $line; } $body[] = ""; return mail($to, $subj, implode($line_break, $body), implode($line_break, $headers)); }
Sorry for the confusion, this is a very old repo that is no longer in use. Please see https://github.com/limetech/webgui
PHP8.x uses the correct line endings in mail [ "\r\n" (CRLF) ] - There's actually a bug open @ php: https://github.com/php/php-src/issues/8086
I actually using this method - because script that are using:
/usr/local/emhttp/webGui/scripts/notify
or/usr/local/emhttp/plugins/dynamix/scripts/notify
may result in error 554 by mail provider -> e.g. https://postmaster.gmx.net/en/case?c=hi&i=ip :