Completed simplified mail sending UI
authorJamie Cameron <jcameron@webmin.com>
Fri, 8 Apr 2011 22:46:13 +0000 (15:46 -0700)
committerJamie Cameron <jcameron@webmin.com>
Fri, 8 Apr 2011 22:46:13 +0000 (15:46 -0700)
webmin/CHANGELOG
webmin/lang/en
webmin/save_sendmail.cgi [new file with mode: 0755]

index 7f4366e..4466418 100644 (file)
@@ -101,3 +101,5 @@ Added a field to the Debugging Log File page to select modules to debug for.
 Added an option to the User Interface page to always put the hostname before the page title.
 ---- Changes since 1.510 ----
 Strong PCI-compliant ciphers can now be selected on the SSL Encryption page.
+---- Changes since 1.540 ----
+Added the Sending Email page which controls how Webmin itself sends messages.
index 24f0b80..3a9b541 100644 (file)
@@ -620,6 +620,7 @@ log_savekey=Uploaded existing SSL key
 log_deletecache=Deleted $1 URLs from cache
 log_clearcache=Cleared all URLs from cache
 log_lock=Changed file locking
+log_sendmail=Changed mail sending options
 
 themes_title=Webmin Themes
 themes_desc=Themes control the appearance of the Webmin user interface, including icons, colours, backgrounds and the layout of pages. The selection box below can be used to choose one of the themes installed on your system.
@@ -920,5 +921,9 @@ sendmail_auth=SMTP authentication method
 sendmail_from=From address for email from Webmin
 sendmail_fromdef=Default ($1)
 sendmail_fromaddr=Address
+sendmail_err=Failed to save mail sending options
+sendmail_esmtp=Missing or un-resolvable SMTP server hostname
+sendmail_elogin=Missing SMTP server login
+sendmail_efrom=Missing or incorrectly formatted from address
 
 __norefs=1
diff --git a/webmin/save_sendmail.cgi b/webmin/save_sendmail.cgi
new file mode 100755 (executable)
index 0000000..91e8935
--- /dev/null
@@ -0,0 +1,51 @@
+#!/usr/local/bin/perl
+# Save mail server settings
+
+require './webmin-lib.pl';
+&ReadParse();
+&error_setup($text{'sendmail_err'});
+&foreign_require("mailboxes");
+&lock_file($mailboxes::module_config_file);
+%mconfig = &foreign_config("mailboxes");
+
+# Save smtp server
+if ($in{'mode'} == 0) {
+       delete($mconfig{'send_mode'});
+       }
+elsif ($in{'mode'} == 1) {
+       $mconfig{'send_mode'} = '127.0.0.1';
+       }
+else {
+       &to_ipaddress($in{'smtp'}) && &to_ip6address($in{'smtp'}) ||
+               &error($text{'sendmail_esmtp'});
+       $mconfig{'send_mode'} = $in{'smtp'};
+       }
+
+# Save login and password
+if ($in{'login_def'}) {
+       delete($mconfig{'smtp_user'});
+       delete($mconfig{'smtp_pass'});
+       }
+else {
+       $in{'login_user'} =~ /^\S+$/ || &error($text{'sendmail_elogin'});
+       $mconfig{'smtp_user'} = $in{'login_user'};
+       $mconfig{'smtp_pass'} = $in{'login_pass'};
+       }
+
+# Save auth method
+$mconfig{'smtp_auth'} = $in{'auth'};
+
+# Save from address
+if ($in{'from_def'}) {
+       delete($mconfig{'webmin_addr'});
+       }
+else {
+       $in{'from'} =~ /^\S+\@\S+$/ || &error($text{'sendmail_efrom'});
+       $mconfig{'webmin_addr'} = $in{'from'};
+       }
+
+&save_module_config(\%mconfig, "mailboxes");
+&unlock_file($mailboxes::module_config_file);
+&webmin_log("sendmail");
+&redirect("");
+