Project

General

Profile

« Previous | Next » 

Revision 02376f6f

Added by Phil Davis over 10 years ago

Check if notification is disabled

in send_smtp_message()
Other packages like arpwatch sm.php and cron job output as reported in forum https://forum.pfsense.org/index.php?topic=88347.0 call send_smtp_message() directly, currently bypassing notification disabled checks. I think those packages [are intended to | should be] respecting the notifications disabled setting. People in the forum certainly expect them to respect this setting.
If we add the $force parameter here, passing it through from notify_via_smtp() then the default behavior of send_smtp_message() can be to respect the "disable" setting. That should stop other package callers from spamming people who have disabled SMTP notifications.
If a package really wants/needs to send regardless, then it can set $force, just like the "Test SMTP" button does.

View differences:

etc/inc/notices.inc
295 295
	fwrite($fd, $message);
296 296
	fclose($fd);
297 297

  
298
	send_smtp_message($message, "{$config['system']['hostname']}.{$config['system']['domain']} - Notification");
298
	send_smtp_message($message, "{$config['system']['hostname']}.{$config['system']['domain']} - Notification", $force);
299 299
	return;
300 300
}
301 301

  
302
function send_smtp_message($message, $subject = "(no subject)") {
302
function send_smtp_message($message, $subject = "(no subject)", $force = false) {
303 303
	global $config, $g;
304 304
	require_once("sasl.inc");
305 305
	require_once("smtp.inc");
306 306

  
307
	if(isset($config['notifications']['smtp']['disable']) && !$force)
308
		return;
309

  
307 310
	if(!$config['notifications']['smtp']['ipaddress'])
308 311
		return;
309 312

  

Also available in: Unified diff