Skip to content

add configuration settings for alert e-mail sender #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions var/www/inc/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
require_once('Mail.php');

/**********************************

Generic functions theat may be called from many differant places

*/

function sendEmail($settings, $subject, $body) {

$mailSettings = array(
'host' => $settings['alertSmtp'],
'host' => $settings['alertSmtp'],
'debug' => false,
'auth' => true,
'username' => $settings['alertSmtpUser'],
'password' => $settings['alertSmtpPwd'],
'port' => $settings['alertSmtpPort'],

);

//$settings['alertDevice']

$mail = Mail::factory('smtp', $mailSettings );

$headers = array('From'=>$settings['alertEmail'], 'Subject'=>$subject);
$headers = array('From'=>$settings['alertEmail'], 'Subject'=>$subject, 'From'=>$settings['alertSender']);
$esito = $mail->send($settings['alertEmail'], $headers, $body);
if (PEAR::isError($esito)) { print($esito->getMessage());}else{print "end";}
}
52 changes: 29 additions & 23 deletions var/www/partials/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ <h3>Mining</h3>
<label class="checkbox-inline">
<input type="checkbox" id="alertEnable" ng-model="settings.alertEnable"> E-mail alerts
</label>

<!-- <label class="checkbox-inline">
<input type="checkbox" id="donateEnable" ng-model="settings.donateEnable"> Enable Donation
<input type="checkbox" id="donateEnable" ng-model="settings.donateEnable"> Enable Donation
</label> -->

<p class="help-block" ng-show="settings.userHelp">
<b>Remote control</b> shares stats with a remote server. Scripta will accept commands from the server.<br />
<b>Automatic recovery</b> responds to alert events by restarting the miner. First gently, then rough.<br />
<b>E-mail alerts</b> send an e-mail when alerts events are fired.<br />
<b>Donation</b> donates a couple of mining minutes to the Scripta project.
</p>
</div>
</div>
</div>
<div class="form-group" ng-show="settings.recoverEnable">
<label for="miningExpHash" class="control-label col-sm-3 col-md-2">Lower limit (hashrate)</label>
<div class="col-sm-3 col-md-4">
Expand Down Expand Up @@ -140,57 +140,63 @@ <h3>Remote control</h3>
</div>
</div>
</fieldset>
<h3>Donate</h3>

<h3>Donate</h3>
<fieldset>
<div class="form-group">
<label for="remoteEnable" class="control-label col-sm-3 col-md-2">Enable</label>
<div class="col-sm-9 col-md-10">
<label class="checkbox-inline">
<input type="checkbox" id="donateEnable" ng-model="settings.donateEnable">
<input type="checkbox" id="donateEnable" ng-model="settings.donateEnable">
</label>
</div>
</div>
</fieldset>
<fieldset ng-show="settings.donateEnable">
<div class="form-group" ng-show="settings.donateEnable">
<label for="donateAmount" class="control-label col-sm-3 col-md-2">Donation minutes</label>
<div class="col-sm-9 col-md-10">
<input type="number" id="donateAmount" ng-model="settings.donateAmount" class="form-control">
<p class="help-block" ng-show="settings.userHelp">
Please donate!
</p>
</div>
</div>
</fieldset>
<fieldset ng-show="settings.donateEnable">
<div class="form-group" ng-show="settings.donateEnable">
<label for="donateAmount" class="control-label col-sm-3 col-md-2">Donation minutes</label>
<div class="col-sm-9 col-md-10">
<input type="number" id="donateAmount" ng-model="settings.donateAmount" class="form-control">
<p class="help-block" ng-show="settings.userHelp">
Please donate!
</p>
</div>
</div>
</fieldset>

<fieldset ng-show="settings.alertEnable">
<h3>E-mail alerts</h3>
<div class="form-group">
<label for="alertDevice" class="control-label col-sm-3 col-md-2">Device Name</label>
<div class="col-sm-9 col-md-10">
<input type="text" id="alertDevice" ng-model="settings.alertDevice" ng-required="settings.alertEnable" class="form-control">
</div>
</div>
</div>
<div class="form-group">
<label for="alertEmail" class="control-label col-sm-3 col-md-2">E-mail</label>
<div class="col-sm-9 col-md-10">
<input type="email" id="alertEmail" ng-model="settings.alertEmail" ng-required="settings.alertEnable" class="form-control">
</div>
</div>
<div class="form-group">
<label for="alertSender" class="control-label col-sm-3 col-md-2">Alert Sender E-mail</label>
<div class="col-sm-9 col-md-10">
<input type="email" id="alertSender" ng-model="settings.alertSender" ng-required="settings.alertEnable" class="form-control">
</div>
</div>
<div class="form-group">
<label for="alertSmtp" class="control-label col-sm-3 col-md-2">SMTP Server address</label>
<div class="col-sm-9 col-md-10">
<input type="text" id="alertSmtp" ng-model="settings.alertSmtp" ng-required="settings.alertEnable" class="form-control">
<p class="help-block" ng-show="settings.userHelp">Please choose your own SMTP server ip address.</p>
</div>
</div>
</div>
<div class="form-group">
<label for="alertSmtp" class="control-label col-sm-3 col-md-2">SMTP Server port</label>
<div class="col-sm-9 col-md-10">
<input type="text" id="alertSmtpPort" ng-model="settings.alertSmtpPort" ng-required="settings.alertEnable" class="form-control" placeholder="25" value="25">
<p class="help-block" ng-show="settings.userHelp">Please choose your own SMTP server port.</p>
</div>
</div>
</div>

<div class="form-group">
Expand All @@ -208,7 +214,7 @@ <h3>E-mail alerts</h3>
</div>
</div>
</fieldset>

<p class="clearfix text-right">
<button type="button" class="btn btn-success" ng-click="sync('settings',settings,1);formMods.$setPristine()" ng-show="formMods.$dirty">Save settings</button>
</p>
Expand Down