<!DOCTYPE html>
<html lang="en">
<?php
    include_once '../account/session.php';
    include_once 'scripts.php';
    $id_manager=$_SESSION['id-manager'];
    $username_manager=$_SESSION['username-manager'];
?>
    
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Manage Servers</title>
    <link type="text/css" href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link type="text/css" href="../../bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">
    <link type="text/css" href="../../css/theme.css" rel="stylesheet">
    <link type="text/css" href="../../images/icons/css/font-awesome.css" rel="stylesheet">
    <link type="text/css" href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600' rel='stylesheet'>
    <script src="../../scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="../../scripts/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
    <script src="../../bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="../../scripts/flot/jquery.flot.js" type="text/javascript"></script>
    <script src="scripts.js" type="text/javascript"></script>
    <script>
        $(document).ready(function(){
        });
    </script>
</head>
<body>
    
    <?php include('../include/inc.top_menu.php'); ?>

    <div class="wrapper">
        <div class="container">
            <div class="row">
                
				<?php include('../include/inc.left_menu.php'); ?>
				
                <div class="span9">
                    <div class="content">
                        <div class="module">
                            <div class="module-head"><h3>RDNS/SPF/PMTA Configurartion &nbsp;<span class="badge badge-success"><?php echo $_GET['name_server'];?></span>&nbsp;&nbsp;&nbsp;<i class="icon-refresh icon-white" title="Refresh" style="cursor: pointer;" onclick="javascript:window.location.reload();"></i><div class="processing" id="processing"></div></h3></div>
                            
                            <div class="module-body">
                                <div class="alert" id="message-warning">
                                    <button type="button" class="close" onclick="close_message_warning();">×</button>
                                    <strong>Warning!</strong> Please verify your data
                                </div>
                                <div class="alert" id="message-warning-custom">
                                    <button type="button" class="close" onclick="close_message_warning_custom();">×</button>
                                    <strong>Warning!</strong> <span id="message-custom"></span>
                                </div>
                                <div class="alert alert-error" id="message-error">
                                    <button type="button" class="close" onclick="close_message_error();">×</button>
                                    <strong>Error!</strong> There was an error while executing your request
                                </div>
                                <div class="alert alert-success" id="message-success">
                                    <button type="button" class="close" onclick="close_message_success();">×</button>
                                    <strong>Done!</strong> Server has been added successfully
                                </div>
                                <div class="form-horizontal row-fluid">
                                    <?php
                                        $query = bd::query("SELECT * FROM server_vmta where id_server='{$_GET['id_server']}'");
                                        while ($row = mysql_fetch_object($query)) 
										{
                                            $list[]=$row;
                                        }
										
										$queryMainIP 	=	bd::query("SELECT * FROM server where id='{$_GET['id_server']}'");
										$row 			=	mysql_fetch_object($queryMainIP);
										$mainIP         =	$row->main_ip;
										
                                    ?>
                                    <h5>IPs/Hostnames</h5>
                                    <textarea class="span6" rows="10" id="header_format" name="config_rdns">
<?php
    foreach($list as $line){
        echo $line->address_ip."\n";
    }
?>
                                    </textarea>
                                    <textarea class="span6" rows="10" id="header_format" name="config_rdns">
<?php
    foreach($list as $line){
        echo $line->host_name."\n";
    }
?>
                                    </textarea>
                                    <br><br>
                                    <h5>RDNS Configuration</h5>
                                    <textarea class="span12" rows="10" id="header_format" name="config_rdns">
<?php
    foreach($list as $line){
        echo $line->address_ip.' '.$line->host_name."\n";
    }
?>
                                    </textarea>
                                    <br><br>
                                    <h5>SPF Configuration</h5>
                                    <textarea class="span12" rows="10" id="header_format" name="config_spf">
<?php
    foreach($list as $line){
        $fqn = explode( '.', $line->host_name);
        if ( count($fqn) == 3 ){
            $domain_sub = $fqn[0];
        }else{
            $domain_sub = '@';
        }
        echo $domain_sub.' '.'v=spf1 ip4:'.$line->address_ip.' -all'."\n";
    }
?>
                                    </textarea>
                                    <br><br>
                                    <h5>PMTA Configuration</h5>
                                    <textarea class="span12" rows="35" id="header_format" name="config_pmta">
#########################Global configuration#####################
Pickup /var/spool/pmtaPickup/Pickup /var/spool/pmtaPickup/BadMail

postmaster servers@globalmediajob.com

#...Logging file name
log-file /var/log/pmta/log
log-file-world-readable false

#...Spool directories
spool /var/spool/pmta

#...Accounting file name
<acct-file /var/log/pmta/acct>
	move-to /var/log/pmtaAccRep/
	move-interval 1d
	records d,b
	world-readable yes
	record-fields d timeLogged,timeQueued,timeImprinted,orig,dsnAction,dsnStatus,dsnDiag,dsnMta,bounceCat,srcType,srcMta,dlvType,dlvSourceIp,dlvDestinationIp,dlvEsmtpAvailable,dlvSize,vmta,jobId
	record-fields b timeLogged,timeQueued,timeImprinted,orig,rcpt,orcpt,dsnAction,dsnStatus,dsnDiag,dsnMta,bounceCat,srcType,srcMta,dlvType,dlvSourceIp,dlvDestinationIp,dlvEsmtpAvailable,dlvSize,vmta,jobId
</acct-file>

<acct-file /var/log/pmtaErr/acct>
	move-to /var/log/pmtaErrRep/
	move-interval 1d
	records t,tq
</acct-file>

#...HTTP management interface
http-mgmt-port 8080
http-access <?php echo $mainIP; ?> monitor
http-access 0/0 monitor

#...relay-domain
<?php
    foreach($list as $line){
        echo 'relay-domain '.$line->host_name."\n";
    }
?>

#...relay-ip
smtp-listener <?php echo $mainIP; ?>:2500
<?php
    foreach($list as $line){
        echo 'smtp-listener '.$line->address_ip.':25'."\n";
    }
?>

#source master : TEST GLOBAL
<source 198.72.112.66>
   always-allow-relaying yes
   smtp-service yes
   process-x-envid true
   process-x-job true
   process-x-virtual-mta true
   add-received-header no
   hide-message-source     true
   remove-header vectparam
   log-connections yes
   log-data no
   log-commands no
</source>

#source local
<source <?php echo $mainIP; ?>>                  
   always-allow-relaying yes
   smtp-service yes
   process-x-envid true
   process-x-job true
   process-x-virtual-mta true
   add-received-header no
   hide-message-source     true
   remove-header vectparam
   log-connections yes
   log-data no
   log-commands no
</source>

<source 0/0>
   always-allow-relaying no
   smtp-service yes
   pattern-list incomingRules
   log-connections yes
   log-data no
   log-commands no
</source>

###################Incoming messages configuration#####################
<pattern-list incomingRules>   
	rcpt-to /^fbl-hotmail@.*$/ virtual-mta=incomingfbl-hotmail
	rcpt-to /^admin@.*$/ virtual-mta=incomingAdmin
	rcpt-to /^contact@.*$/ virtual-mta=incomingContact
	rcpt-to /^contactus@.*$/ virtual-mta=incomingContactus
	rcpt-to /^info@.*$/ virtual-mta=incomingInfo
	rcpt-to /^mail@.*$/ virtual-mta=incomingMail
	rcpt-to /^support@.*$/ virtual-mta=incomingSupport
	rcpt-to /^tech@.*$/ virtual-mta=incomingTech
	rcpt-to /^webmaster@.*$/ virtual-mta=incomingWebmaster
	rcpt-to /^listunsub@.*$/ virtual-mta=incomingListunsub  
	rcpt-to /^postmaster@.*$/ virtual-mta=incomingPostm
	rcpt-to /^abuse@.*$/ virtual-mta=incomingAbuse
	rcpt-to /^return@.*$/ virtual-mta=incomingBounce
	rcpt-to /^helpme@.*$/ virtual-mta=incomingHelpme
	rcpt-to /^helpus@.*$/ virtual-mta=incomingHelpus
	rcpt-to /^help@.*$/ virtual-mta=incomingHelp
	rcpt-to /^manage@.*$/ virtual-mta=incomingManage
	rcpt-to /^sales@.*$/ virtual-mta=incomingSales
	rcpt-to /^report@.*$/ virtual-mta=incomingReport
	rcpt-to /^techsupportme@.*$/ virtual-mta=incomingTechsupportme
	rcpt-to /^techsupport@.*$/ virtual-mta=incomingTechsupport
	rcpt-to /^techsupportus@.*$/ virtual-mta=incomingTechsupportus
	rcpt-to /^billing@.*$/ virtual-mta=incomingBilling
	rcpt-to /^server247@.*$/ virtual-mta=incomingServer247
	rcpt-to /^mywebsite@.*$/ virtual-mta=incomingMywebsite
	rcpt-to /^docs@.*$/ virtual-mta=incomingDocs
	rcpt-to /^notification@.*$/ virtual-mta=incomingNotification
	rcpt-to /^provisioning@.*$/ virtual-mta=incomingProvisioning
	rcpt-to /^provisioning_customer@.*$/ virtual-mta=incomingProvisioning_customer
	rcpt-to /^project@.*$/ virtual-mta=incomingProject
	rcpt-to /^design@.*$/ virtual-mta=incomingDesign
	rcpt-to /^support24@.*$/ virtual-mta=incomingSupport24
	rcpt-to /^develop@.*$/ virtual-mta=incomingDevelop
	rcpt-to /^guideus@.*$/ virtual-mta=incomingGuideus
	rcpt-to /^guide@.*$/ virtual-mta=incomingGuide
	rcpt-to /^netsolution@.*$/ virtual-mta=incomingNetsolution
	rcpt-to /^techsystem@.*$/ virtual-mta=incomingTechsystem
	rcpt-to /^system@.*$/ virtual-mta=incomingSystem
	rcpt-to /^express@.*$/ virtual-mta=incomingExpress
	rcpt-to /.*@.*$/ virtual-mta=incomingReply
</pattern-list>

<virtual-mta incomingfbl-hotmail>      
  <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/fbl-hotmail
   </domain>
</virtual-mta>
 
<virtual-mta incomingAdmin>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/admin
   </domain>
</virtual-mta>
 
<virtual-mta incomingContact>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/contact
   </domain>
</virtual-mta>
    
<virtual-mta incomingContactus>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/contactus
   </domain>
</virtual-mta>
    
<virtual-mta incomingInfo>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/info
   </domain>
</virtual-mta>
   
<virtual-mta incomingMail>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/mail
   </domain>
</virtual-mta>
  
<virtual-mta incomingSupport>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/support
   </domain>
</virtual-mta>
 
 
<virtual-mta incomingTech>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/tech
   </domain>
</virtual-mta>
 
<virtual-mta incomingWebmaster>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/webmaster
   </domain>
</virtual-mta>


<virtual-mta incomingPostm>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/postm
   </domain>
</virtual-mta>

<virtual-mta incomingHelpme>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/helpme
   </domain>
</virtual-mta>

 <virtual-mta incomingHelpus>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/helpus
   </domain>
</virtual-mta>

 <virtual-mta incomingHelp>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/help
   </domain>
</virtual-mta>

 <virtual-mta incomingManage>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/manage
   </domain>
</virtual-mta>

 <virtual-mta incomingSales>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/sales
   </domain>
</virtual-mta>

 <virtual-mta incomingReport>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/report
   </domain>
</virtual-mta>

 <virtual-mta incomingTechsupportme>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/techsupportme
   </domain>
</virtual-mta>

 <virtual-mta incomingTechsupport>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/techsupport
   </domain>
</virtual-mta>

 <virtual-mta incomingTechsupportus>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/techsupportus
   </domain>
</virtual-mta>

 <virtual-mta incomingBilling>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/billing
   </domain>
</virtual-mta>

 <virtual-mta incomingServer247>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/server247
  </domain>
</virtual-mta>

 <virtual-mta incomingMywebsite>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/mywebsite
   </domain>
</virtual-mta>

 <virtual-mta incomingDocs>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/docs
   </domain>
</virtual-mta>

 <virtual-mta incomingNotification>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/notification
   </domain>
</virtual-mta>

 <virtual-mta incomingProvisioning>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/provisioning
   </domain>
</virtual-mta>

 <virtual-mta incomingProvisioning_customer>
  <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/provisioning_customer
   </domain>
</virtual-mta>

 <virtual-mta incomingProject>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/project
   </domain>
</virtual-mta>

 <virtual-mta incomingDesign>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/design
   </domain>
</virtual-mta>

 <virtual-mta incomingSupport24>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/support24
   </domain>
</virtual-mta>

 <virtual-mta incomingDevelop>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/develop
   </domain>
</virtual-mta>

 <virtual-mta incomingGuideus>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/guideus
   </domain>
</virtual-mta>

 <virtual-mta incomingGuide>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/guide
   </domain>
</virtual-mta>

 <virtual-mta incomingNetsolution>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/netsolution
   </domain>
</virtual-mta>

 <virtual-mta incomingTechsystem>
   <domain *>
      type file
     file-format append-mbox
      file-destination /var/spool/pmtaIncoming/techsystem
   </domain>
</virtual-mta>

 <virtual-mta incomingSystem>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/system
   </domain>
</virtual-mta>

 <virtual-mta incomingExpress>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/express
   </domain>
</virtual-mta>

<virtual-mta incomingListunsub>
   <domain *>
      type pipe
      command "/etc/smrsh/listunsubscribe.php --envid \"$envid\" \"$user\""
   </domain>
</virtual-mta>

#<virtual-mta incomingAbuse> 
   #<domain *>
  #    type pipe
 #     command "/etc/smrsh/unsubs.php --envid \"$envid\" \"$user\""
#   </domain>
#</virtual-mta>

<virtual-mta incomingAbuse>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/abuse
   </domain>
</virtual-mta>

<virtual-mta incomingBounce>
   <domain *>
      type file
      file-format append-mbox
      file-destination /var/spool/pmtaIncoming/bounce
   </domain>
</virtual-mta>

#<virtual-mta incomingBounce>
   #<domain *>
   #   type pipe
  #    command "/etc/smrsh/bounce.php --envid \"$envid\" \"$user\""
 #  </domain>
#</virtual-mta>

<virtual-mta incomingReply>
   <domain *>
      type pipe
      command "/etc/smrsh/unsubs.php --envid \"$envid\" \"$user\""
   </domain>
</virtual-mta>

###################Outgoing messages configuration#####################
<domain gmail.com>
	dk-sign yes
	dkim-sign yes
	retry-after 10m
	bounce-after 24h
    log-transfer-failures yes
	log-connections yes
	log-commands no
    log-data no
	max-smtp-out 1200
</domain>

domain-macro hotmail hotmail, outlook, msn, live
domain-macro htld com, de, co.uk, es, fr

<domain $hotmail.$htld>
    dk-sign yes               
    dkim-sign yes
    retry-after 10m
    bounce-after 24h
    max-smtp-out 60        
    max-msg-per-connection 100
    421-means-mx-unavailable yes
    queue-priority 100
    log-transfer-failures yes
    log-connections yes
    log-commands no
    log-data no                  
</domain>

domain-macro aol aol, aim, wmconnect, netscape, cs, compuserve, luckymail, icqmail
domain-macro topLevel com, de, co.uk, net

<domain $aol.$topLevel>
    dk-sign yes
    dkim-sign yes
    log-transfer-failures yes
    retry-after 10m
    bounce-after 24h
    log-connections yes
    log-commands no
    log-data no
    max-smtp-out 500
    max-msg-per-connection 1200
</domain>

domain-macro yahoo yahoo.com, ymail.com, rocketmail.com

<domain $yahoo>
	dk-sign no
	dkim-sign no
	log-transfer-failures yes
	retry-after 2m
	bounce-after 24h
	log-connections yes
	log-commands no
        log-data no
	max-smtp-out 1200
	max-msg-per-connection 100
</domain>

<domain comcast.net>
    #dk-sign yes
    #dkim-sign yes
    log-transfer-failures yes
    retry-after 3m
    bounce-after 24h
    log-connections yes
    log-commands no
    log-data no
    max-smtp-out 30
    max-msg-per-connection 100
</domain>

<domain cox.net>
    #dk-sign yes
    #dkim-sign yes
    log-transfer-failures yes
    retry-after 3m
    bounce-after 24h
    log-connections yes
    log-commands no
    log-data no
    max-smtp-out 25
    max-msg-per-connection 80
</domain>

<domain sbcglobal.net>
    dk-sign yes
    dkim-sign yes
    log-transfer-failures yes
    retry-after 10m
    bounce-after 24h
    log-connections yes
    log-commands no
    log-data no
    max-smtp-out 1200
</domain>


<domain att.net>
	dk-sign yes
	dkim-sign yes
	log-transfer-failures yes
	retry-after 10m
	bounce-after 24h
	log-connections yes
	log-commands no
        log-data no
	max-smtp-out 50
	max-msg-per-connection 100
</domain>

<domain bellsouth.net>
	dk-sign yes
	dkim-sign yes
	log-transfer-failures yes
	retry-after 10m
	bounce-after 24h
	log-connections yes
	log-commands no
        log-data no
	max-smtp-out 50
	max-msg-per-connection 100
</domain>

<domain *>
    dk-sign yes
    dkim-sign yes
    log-transfer-failures yes
    retry-after 10m
    bounce-after 24h
    log-connections yes
    log-commands no
    log-data no
    max-smtp-out 200 
</domain>

###################Vmtas configuration#####################
include /var/www/app/mailer/server/vmta/config.d/vmtas.txt
<?php
    foreach($list as $line){
        $fqn = explode( '.', $line->host_name);
        if ( count($fqn) == 3 ){
            $domain_sub = $fqn[1].'.'.$fqn[2];
        }else{
            $domain_sub = $fqn[0].'.'.$fqn[1];
        }
        echo '<virtual-mta '.$line->name.'>'."\n";
        echo '  smtp-source-ip '.$line->address_ip."\n";
        echo '  host-name '.$line->host_name."\n";
        echo '  domain-key '.'Dk,'.$line->host_name.',/etc/pmta/domainKeys/Dk.'.$domain_sub.'.pem'."\n";
        echo '</virtual-mta>'."\n\n";
    }
?>
                                    </textarea>
                                    <br><br>
                                    <button class="btn btn-primary" type="button" onclick="add();">Add Server</button>
                                    <button class="btn btn-default" type="button" onclick="location.href='show.php'">Back to show</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div><!--/.content-->
                </div><!--/.span9-->
            </div>
        </div><!--/.container-->
    </div><!--/.wrapper-->

</body>
