diff options
author | Danilo G. Baio (dbaio) <dbaio@bsd.com.br> | 2016-07-27 15:02:13 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2016-08-19 09:28:55 -0300 |
commit | f28a0383e28aafad4a53842a3e619094fabb6a6a (patch) | |
tree | 84d7dab527fa2549a166e3e5607a544690aeba39 | |
parent | 8fa505d20ebde212901caba607a882652fb7b938 (diff) | |
download | FreeBSD-ports-f28a0383e28aafad4a53842a3e619094fabb6a6a.zip FreeBSD-ports-f28a0383e28aafad4a53842a3e619094fabb6a6a.tar.gz |
apcupsd - replace phpMailer to send_smtp_message()
(cherry picked from commit cab4f7c85b82815656c84d09ee80b82c5ff944ee)
-rw-r--r-- | sysutils/pfSense-pkg-apcupsd/Makefile | 3 | ||||
-rw-r--r-- | sysutils/pfSense-pkg-apcupsd/files/usr/local/pkg/apcupsd.xml | 6 | ||||
-rwxr-xr-x | sysutils/pfSense-pkg-apcupsd/files/usr/local/pkg/apcupsd_mail.php | 47 |
3 files changed, 11 insertions, 45 deletions
diff --git a/sysutils/pfSense-pkg-apcupsd/Makefile b/sysutils/pfSense-pkg-apcupsd/Makefile index f8b2a02..ad23e19 100644 --- a/sysutils/pfSense-pkg-apcupsd/Makefile +++ b/sysutils/pfSense-pkg-apcupsd/Makefile @@ -12,8 +12,7 @@ COMMENT= pfSense package apcupsd LICENSE= ESF -RUN_DEPENDS= ${LOCALBASE}/sbin/apcupsd:sysutils/apcupsd \ - /etc/inc/phpmailer/PHPMailerAutoload.php:mail/pfSense-pkg-mailreport +RUN_DEPENDS= ${LOCALBASE}/sbin/apcupsd:sysutils/apcupsd NO_BUILD= yes NO_MTREE= yes diff --git a/sysutils/pfSense-pkg-apcupsd/files/usr/local/pkg/apcupsd.xml b/sysutils/pfSense-pkg-apcupsd/files/usr/local/pkg/apcupsd.xml index e451a10..8f52f69 100644 --- a/sysutils/pfSense-pkg-apcupsd/files/usr/local/pkg/apcupsd.xml +++ b/sysutils/pfSense-pkg-apcupsd/files/usr/local/pkg/apcupsd.xml @@ -342,8 +342,8 @@ <description> <![CDATA[ Choose how APCUpsd will send email notifications.<br /><br /> - <strong>phpMailer</strong> - In order to receive e-mail notifications through phpMailer, you need to configure SMTP Email Notifications on Advanced/Notifications section, - and also install mailreport package.<br /> + <strong>php</strong> - In order to receive e-mail notifications through php, you need to configure SMTP Email Notifications + on System/Advanced/Notifications section.<br /> <br /> <strong>SMTP built-in</strong> - A simple SMTP mail client for apcupsd. It does not have smtp authentication of any kind. ]]> @@ -351,7 +351,7 @@ <type>select</type> <default_value>phpmailer</default_value> <options> - <option><name>phpMailer</name><value>phpmailer</value></option> + <option><name>php</name><value>phpmailer</value></option> <option><name>SMTP built-in</name><value>smtpbuiltin</value></option> </options> </field> diff --git a/sysutils/pfSense-pkg-apcupsd/files/usr/local/pkg/apcupsd_mail.php b/sysutils/pfSense-pkg-apcupsd/files/usr/local/pkg/apcupsd_mail.php index 17e18a9..0727ef0 100755 --- a/sysutils/pfSense-pkg-apcupsd/files/usr/local/pkg/apcupsd_mail.php +++ b/sysutils/pfSense-pkg-apcupsd/files/usr/local/pkg/apcupsd_mail.php @@ -29,7 +29,7 @@ */ require_once("pkg-utils.inc"); require_once("globals.inc"); -require_once("phpmailer/PHPMailerAutoload.php"); +require_once("notices.inc"); global $config, $g; @@ -53,49 +53,16 @@ if (empty($argv[1]) || empty($apcstatus["$argv[1]"])) { return; } -$apcsubject = $apcstatus["$argv[1]"]; - -if (empty($config['notifications']['smtp']['ipaddress'])) { - return; -} - -$mail = new PHPMailer(); -$mail->IsSMTP(); -$mail->Host = $config['notifications']['smtp']['ipaddress']; - -if ((isset($config['notifications']['smtp']['ssl']) && $config['notifications']['smtp']['ssl'] != "unchecked") || $config['notifications']['smtp']['ssl'] == "checked") { - $mail->SMTPSecure = "ssl"; -} - -if ((isset($config['notifications']['smtp']['tls']) && $config['notifications']['smtp']['tls'] != "unchecked") || $config['notifications']['smtp']['tls'] == "checked") { - $mail->SMTPSecure = "tls"; -} - -$mail->Port = empty($config['notifications']['smtp']['port']) ? 25 : $config['notifications']['smtp']['port']; - -if ($config['notifications']['smtp']['username'] && $config['notifications']['smtp']['password']) { - $mail->SMTPAuth = true; - $mail->Username = $config['notifications']['smtp']['username']; - $mail->Password = $config['notifications']['smtp']['password']; -} - -$mail->ContentType = 'text/html'; -$mail->IsHTML(true); -$mail->AddReplyTo($config['notifications']['smtp']['fromaddress'], "Apcupsd"); -$mail->SetFrom($config['notifications']['smtp']['fromaddress'], "Apcupsd"); -$address = $config['notifications']['smtp']['notifyemailaddress']; -$mail->AddAddress($address, "Apcupsd Recipient"); -$mail->Subject = "{$config['system']['hostname']}.{$config['system']['domain']} - {$apcsubject}"; +$apcsubject = "apcupsd - " . $apcstatus["$argv[1]"]; +$apcmessage = "Status information from apcupsd:\n"; putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"); -$mail->Body = "<pre>"; $ph = popen('apcaccess status 2>&1', "r" ); -while ($line = fgets($ph)) $mail->Body .= htmlspecialchars($line); +while ($line = fgets($ph)) { + $apcmessage .= $line; +} pclose($ph); -$mail->Body .= "</pre>"; -if (!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} +send_smtp_message($apcmessage, $apcsubject); ?> |