Skip to content
This repository has been archived by the owner on Jun 17, 2023. It is now read-only.

[BUG] (PHP8.x - mail()) Notify #271

Closed
realizelol opened this issue Jun 2, 2023 · 1 comment
Closed

[BUG] (PHP8.x - mail()) Notify #271

realizelol opened this issue Jun 2, 2023 · 1 comment

Comments

@realizelol
Copy link

realizelol commented Jun 2, 2023

PHP8.x uses the correct line endings in mail [ "\r\n" (CRLF) ] - There's actually a bug open @ php:
php/php-src#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 :

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));
}
@realizelol realizelol changed the title [BUG] (PHP8.x Notify [BUG] (PHP8.x) Notify Jun 2, 2023
@realizelol realizelol changed the title [BUG] (PHP8.x) Notify [BUG] (PHP8.x - mail()) Notify Jun 2, 2023
@ljm42
Copy link

ljm42 commented Jun 2, 2023

Sorry for the confusion, this is a very old repo that is no longer in use. Please see https://github.com/limetech/webgui

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants