Menu

[r10367]: / legacy / www / system_email.php  Maximize  Restore  History

Download this file

183 lines (162 with data), 8.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/local/bin/php
<?php
/*
system_email.php
Copyright (C) 2006-2010 Volker Theile (votdev@gmx.de)
All rights reserved.
part of FreeNAS (http://www.freenas.org)
Copyright (C) 2005-2010 Olivier Cochard <olivier@freenas.org>.
All rights reserved.
Based on m0n0wall (http://m0n0.ch/wall)
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require("auth.inc");
require("guiconfig.inc");
require("email.inc");
$pgtitle = array(gettext("System"),gettext("Advanced"),gettext("Email"));
if (!is_array($config['system']['email'])) {
$config['system']['email'] = array();
}
$pconfig['server'] = $config['system']['email']['server'];
$pconfig['port'] = $config['system']['email']['port'];
$pconfig['auth'] = isset($config['system']['email']['auth']);
$pconfig['authmethod'] = $config['system']['email']['authmethod'];
$pconfig['security'] = $config['system']['email']['security'];
$pconfig['username'] = $config['system']['email']['username'];
$pconfig['password'] = $config['system']['email']['password'];
$pconfig['passwordconf'] = $pconfig['password'];
$pconfig['from'] = $config['system']['email']['from'];
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
$reqdfields = array();
$reqdfieldsn = array();
$reqdfieldst = array();
if ($_POST['auth']) {
$reqdfields = array_merge($reqdfields, array("username", "password"));
$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Username"), gettext("Password")));
$reqdfieldst = array_merge($reqdfieldst, array("string","string"));
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, &$input_errors);
// Check for a password mismatch.
if ($_POST['auth'] && ($_POST['password'] !== $_POST['passwordconf'])) {
$input_errors[] = gettext("The passwords do not match.");
}
if (!$input_errors) {
$config['system']['email']['server'] = $_POST['server'];
$config['system']['email']['port'] = $_POST['port'];
$config['system']['email']['auth'] = $_POST['auth'] ? true : false;
$config['system']['email']['authmethod'] = $_POST['authmethod'];
$config['system']['email']['security'] = $_POST['security'];
$config['system']['email']['username'] = $_POST['username'];
$config['system']['email']['password'] = $_POST['password'];
$config['system']['email']['from'] = $_POST['from'];
write_config();
$retval = 0;
if (!file_exists($d_sysrebootreqd_path)) {
config_lock();
$retval |= rc_exec_service("msmtp");
config_unlock();
}
// Send test email.
if (stristr($_POST['Submit'], gettext("Send test email"))) {
$subject = sprintf(gettext("Test email from host: %s"), system_get_hostname());
$message = gettext("This email has been send to validate your email configuration.");
$retval = @email_send($config['system']['email']['from'], $subject, $message, $error);
if (0 == $retval) {
$savemsg = gettext("Test email successfully sent.");
write_log(sprintf(gettext("Test email successfully sent to: %s."), $config['system']['email']['from']));
} else {
$failmsg = sprintf(gettext("Failed to send test email. Please check the <a href='%s'>log</a> files."), "diag_log.php");
write_log(sprintf(gettext("Failed to send test email to: %s."), $config['system']['email']['from']));
}
} else {
$savemsg = get_std_save_message($retval);
}
}
}
?>
<?php include("fbegin.inc");?>
<script type="text/javascript">
<!--
function auth_change() {
switch (document.iform.auth.checked) {
case false:
showElementById('username_tr','hide');
showElementById('password_tr','hide');
showElementById('authmethod_tr','hide');
break;
case true:
showElementById('username_tr','show');
showElementById('password_tr','show');
showElementById('authmethod_tr','show');
break;
}
}
//-->
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="tabnavtbl">
<ul id="tabnav">
<li class="tabinact"><a href="system_advanced.php"><span><?=gettext("Advanced");?></span></a></li>
<li class="tabact"><a href="system_email.php" title="<?=gettext("Reload page");?>"><span><?=gettext("Email");?></span></a></li>
<li class="tabinact"><a href="system_proxy.php"><span><?=gettext("Proxy");?></span></a></li>
<li class="tabinact"><a href="system_swap.php"><span><?=gettext("Swap");?></span></a></li>
<li class="tabinact"><a href="system_rc.php"><span><?=gettext("Command scripts");?></span></a></li>
<li class="tabinact"><a href="system_cron.php"><span><?=gettext("Cron");?></span></a></li>
<li class="tabinact"><a href="system_rcconf.php"><span><?=gettext("rc.conf");?></span></a></li>
<li class="tabinact"><a href="system_sysctl.php"><span><?=gettext("sysctl.conf");?></span></a></li>
</ul>
</td>
</tr>
<tr>
<td class="tabcont">
<form action="system_email.php" method="post" name="iform" id="iform">
<?php if ($input_errors) print_input_errors($input_errors);?>
<?php if ($savemsg) print_info_box($savemsg);?>
<?php if ($failmsg) print_error_box($failmsg);?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<?php html_inputbox("from", gettext("From email"), $pconfig['from'], gettext("Your own email address."), true, 40);?>
<?php html_inputbox("server", gettext("Outgoing mail server"), $pconfig['server'], gettext("Outgoing SMTP mail server address, e.g. smtp.mycorp.com."), true, 40);?>
<?php html_inputbox("port", gettext("Port"), $pconfig['port'], gettext("The default SMTP mail server port, e.g. 25 or 587."), true, 10);?>
<?php html_combobox("security", gettext("Security"), $pconfig['security'], array("none" => gettext("None"), "ssl" => "SSL", "tls" => "TLS"), "", true);?>
<?php html_checkbox("auth", gettext("Authentication"), $pconfig['auth'] ? true : false, gettext("Enable SMTP authentication."), "", false, "auth_change()");?>
<?php html_inputbox("username", gettext("Username"), $pconfig['username'], "", true, 40);?>
<?php html_passwordconfbox("password", "passwordconf", gettext("Password"), $pconfig['password'], $pconfig['passwordconf'], "", true);?>
<?php html_combobox("authmethod", gettext("Authentication method"), $pconfig['authmethod'], array("plain" => "Plain", "cram-md5" => "Cram-MD5", "digest-md5" => "Digest-MD5", "gssapi" => "GSSAPI", "external" => "External", "login" => "Login", "ntlm" => "NTLM", "on" => gettext("Best available")), "", true);?>
</table>
<div id="submit">
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
<input name="Submit" id="sendnow" type="submit" class="formbtn" value="<?=gettext("Send test email");?>" />
</div>
<?php include("formend.inc");?>
</form>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
auth_change();
//-->
</script>
<?php include("fend.inc");?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.