mailwatch / MailWatch

MailWatch for MailScanner is a web-based front-end to MailScanner
http://mailwatch.org/
GNU General Public License v2.0
117 stars 66 forks source link

PHP issues each time I try to run /usr/local/bin/mailwatch_sendmail_relay.php #1272

Closed TuxBel closed 1 year ago

TuxBel commented 1 year ago

Issue summary

Whenever I try to run /usr/local/bin/mailwatch_sendmail_relay.php from command-line (bash) I get the following errors: [root@bluewall ~]# /usr/local/bin/mailwatch_sendmail_relay.php

Notice: Constant VIRUS_INFO already defined in /var/www/html/mailscanner/conf.php on line 209

Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /var/www/html/mailscanner/functions.php on line 44

Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /var/www/html/mailscanner/functions.php on line 45

Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /var/www/html/mailscanner/functions.php on line 46

Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /var/www/html/mailscanner/functions.php on line 47

Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /var/www/html/mailscanner/functions.php on line 51

Warning: session_name(): Cannot change session name when headers already sent in /var/www/html/mailscanner/functions.php on line 58

Warning: session_set_cookie_params(): Cannot change session cookie parameters when headers already sent in /var/www/html/mailscanner/functions.php on line 60

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/mailscanner/conf.php:209) in /var/www/html/mailscanner/functions.php on line 73

Steps to reproduce

  1. run # usr/local/bin/mailwatch_sendmail_relay.php

Expected result

Relay results from /var/log/maillog to be displayed in MailWatch

Actual result

Php script dies and nothing occurs

Installation

Version and method

Server configuration

Client configuration

endelwar commented 1 year ago

Does this error appears when you run path/to/php /usr/local/bin/mailwatch_sendmail_relay.php?

TuxBel commented 1 year ago

Yes that happens always, even while invoking with /usr/bin/php /usr/local/bin/mailwatch_sendmail_relay.php Always the same result.

[root@bluewall incoming]# /usr/bin/php /usr/local/bin/mailwatch_sendmail_relay.php

Notice: Constant VIRUS_INFO already defined in /var/www/html/mailscanner/conf.php on line 209

Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /var/www/html/mailscanner/functions.php on line 44

Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /var/www/html/mailscanner/functions.php on line 45

Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /var/www/html/mailscanner/functions.php on line 46

Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /var/www/html/mailscanner/functions.php on line 47

Warning: session_name(): Cannot change session name when headers already sent in /var/www/html/mailscanner/functions.php on line 58

Warning: session_set_cookie_params(): Cannot change session cookie parameters when headers already sent in /var/www/html/mailscanner/functions.php on line 60

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/mailscanner/conf.php:209) in /var/www/html/mailscanner/functions.php on line 73

TuxBel commented 1 year ago

I think I solved it a double config line was set for VIRUS_INFO define('VIRUS_INFO', 'http://www.rainingfrogs.co.uk/index.php?virus=%s&search=contains&Search=Search'); define('VIRUS_INFO', true);

I modified to: // define('VIRUS_INFO', 'http://www.rainingfrogs.co.uk/index.php?virus=%s&search=contains&Search=Search'); define('VIRUS_INFO', false);

And then I no longer get any error message when I load: /usr/bin/php /usr/local/bin/mailwatch_sendmail_relay.php

BUT I get absolutely no routing info on the Message Details... The systemd file to run it I created is:

=-=-=-=-=-=-=-=-=-=-=-=-= [Unit] Description=Sendmail relay service for MailWatch SourcePath=/usr/local/bin/mailwatch_sendmail_relay.php After=network-online.target remote-fs.target rsyslog.service ms-sendmail.service mailscanner.service Wants=network-online.target ms-sendmail.service mailscanner.service

[Service] Type=simple Restart=always TimeoutSec=1min RemainAfterExit=no ExecStart=/usr/bin/php -q /usr/local/bin/mailwatch_sendmail_relay.php

[Install] WantedBy=multi-user.target =-=-=-=-=-=-=-=-=-=-=-=-=

When I invoke (as root) systemctl status mailwatch-sendmail-relay.service I get: systemctl status mailwatch-sendmail-relay.service ● mailwatch-sendmail-relay.service - Sendmail relay service for MailWatch Loaded: loaded (/usr/local/bin/mailwatch_sendmail_relay.php; enabled; vendor preset: disabled) Active: active (running) since dim. 2023-01-15 22:06:53 CET; 4min 32s ago Main PID: 6460 (php) CGroup: /system.slice/mailwatch-sendmail-relay.service ├─6460 /usr/bin/php -q /usr/local/bin/mailwatch_sendmail_relay.php └─6464 tail -F -n0 /var/log/maillog

janv. 15 22:06:53 bluewall.bbsoft4.org systemd[1]: Stopped Sendmail relay service for MailWatch. janv. 15 22:06:53 bluewall.bbsoft4.org systemd[1]: Started Sendmail relay service for MailWatch.

But no relay infos appear... Could that be related to the entries in /var/log/maillog not correctly referenced in /usr/bin/php /usr/local/bin/mailwatch_sendmail_relay.php ? Or could that be related to php.ini missing some entries ? I really would like to solve that issue with MailWatch on CentOS 7...