]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/mail.cgi
dns.cgi: Perform kdig tests only if the system is online.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / mail.cgi
index 072888cb4baaf501bc3317b22a34684946942f29..25589046e6abcf5d2f1111237c177212a723bc8b 100755 (executable)
@@ -81,19 +81,10 @@ if ( -f $mailfile){
 
 #ACTIONS
 if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}"){ #SaveButton on configsite
-       #Check fields
-       if ($cgiparams{'USEMAIL'} eq 'on'){
-               $errormessage=&checkmailsettings;
-       }else{
-               $cgiparams{'txt_mailserver'}='';
-               $cgiparams{'txt_mailport'}='';
-               $cgiparams{'txt_mailuser'}='';
-               $cgiparams{'txt_mailpass'}='';
-               $cgiparams{'mail_tls'}='';
-               $cgiparams{'txt_mailsender'}='';
-               $cgiparams{'txt_recipient'}='';
-       }
-       if(!$errormessage){
+       # Check fields
+       $errormessage = &checkmailsettings();
+
+       if (!$errormessage) {
                #clear hashes
                %auth=();
                %dma=();
@@ -153,12 +144,15 @@ sub configsite{
 
        #If update set fieldvalues new
        if($cgiparams{'update'} eq 'on'){
-               $dma{'USEMAIL'}= 'on';
+               $mail{'USEMAIL'}        = 'on';
+               $mail{'SENDER'}         =  $cgiparams{'txt_mailsender'};
+               $mail{'RECIPIENT'}      =  $cgiparams{'txt_recipient'};
                $dma{'SMARTHOST'}       = $cgiparams{'txt_mailserver'};
                $dma{'PORT'}            = $cgiparams{'txt_mailport'};
-               $auth{'AUTHUSER'}       = $cgiparams{'txt_mailuser'};
+               $auth{'AUTHNAME'}       = $cgiparams{'txt_mailuser'};
                $auth{'AUTHHOST'}       = $cgiparams{'txt_mailserver'};
                $auth{'AUTHPASS'}       = $cgiparams{'txt_mailpass'};
+               $dma{'STARTTLS'}        = $cgiparams{'mail_tls'};
        }
        #find preselections
        $checked{'usemail'}{$mail{'USEMAIL'}}   = 'CHECKED';
@@ -235,7 +229,7 @@ END
                        <td><input type='checkbox' name='mail_tls' $checked{'mail_tls'}{'on'}></td>
                </tr>
 END
-               if (! -z $dmafile && $mail{'USEMAIL'} eq 'on'){
+               if (! -z $dmafile && $mail{'USEMAIL'} eq 'on' && !$errormessage){
                        print "<tr>";
                        print "<td></td>";
                        print "<td><input type='submit' name='ACTION' value='$Lang::tr{'email testmail'}'></td>";
@@ -266,21 +260,21 @@ sub checkmailsettings {
        #Check if mailserver is an ip address or a domain
        if ($cgiparams{'txt_mailserver'} =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/){
                if (! &General::validip($cgiparams{'txt_mailserver'})){
-                       $errormessage.="$Lang::tr{'email invalid mailip'} $cgiparams{'txt_mailserver'}<br>";
+                       $errormessage .= $Lang::tr{'email invalid mailip'} . "<br>";
                }
        }elsif(! &General::validfqdn($cgiparams{'txt_mailserver'})){
-                       $errormessage.="$Lang::tr{'email invalid mailfqdn'} $cgiparams{'txt_mailserver'}<br>";
+                       $errormessage .= $Lang::tr{'email invalid mailfqdn'} . "<br>";
        }
        #Check valid mailserverport
        if($cgiparams{'txt_mailport'} < 1 || $cgiparams{'txt_mailport'} > 65535){
-               $errormessage.="$Lang::tr{'email invalid mailport'} $cgiparams{'txt_mailport'}<br>";
+               $errormessage .= $Lang::tr{'email invalid mailport'} . "<br>";
        }
        #Check valid sender
        if(! $cgiparams{'txt_mailsender'}){
-               $errormessage.="$Lang::tr{'email empty field'} $Lang::tr{'email mailsender'}<br>";
+               $errormessage .= $Lang::tr{'email empty field'} . "<br>";
        }else{
                if (! &General::validemail($cgiparams{'txt_mailsender'})){
-                       $errormessage.="<br>$Lang::tr{'email invalid'} $Lang::tr{'email mailsender'}<br>";
+                       $errormessage .= "$Lang::tr{'email invalid'} $Lang::tr{'email mailsender'}<br>";
                }
        }
        return $errormessage;