File: config

package info (click to toggle)
exim 3.36-18.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,684 kB
  • ctags: 3,574
  • sloc: ansic: 52,492; sh: 1,172; perl: 577; makefile: 343
file content (1165 lines) | stat: -rw-r--r-- 39,143 bytes parent folder | download
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
#!/usr/bin/perl --
#
# Semiautomatic configuration script for Debian's Exim package.
# Used after installation to configure a mail system, and can be run
# at any later time (though --force may be needed).
#
# Originally written for smail by Ian Jackson.
# Modified for exim by Tim Cutts.
# Modified further by Mark Baker.
#
# Copyright 1994-1999 Ian Jackson, Tim Cutts and Mark Baker
# There is no warranty
#
# See /usr/share/doc/exim for more information.
#
# This is _horrible_ code. I feel sorry for anyone who has to modify it
# Some day I'll rewrite it.

# Ensure umask is correct
umask 022;

# Turn on autoflush 
$|=1;

# Setting this to something other than /etc may be useful for testing
$etc='/etc';

# Check whether called with -i option
if( $ARGV[0] eq "-i" ) {
    print "Starting exim\n" ;

    # Install in inetd
    system( 'update-inetd --group MAIL --comment-chars \#disabled\# --add ' .
    '"smtp		stream	tcp	nowait	mail	/usr/sbin/exim exim -bs"' ) ;

    # Install in init.d
    system( 'update-rc.d exim defaults >/dev/null' ) ;

    # Restart daemon
    system( ' invoke-rc.d exim start' ) ;

    exit 0 ;
}

# Quit if not run as root
if( ( -e "$etc/exim/exim.conf" && ! -w "$etc/exim/exim.conf" ) || ! -w "$etc" ) {
    print "eximconfig requires write access to /etc/exim/exim.conf. You should ".
      "run it as root.\n" ;

    exit 1 ;
}

# Regexps for checking domain names
$rfc1035_label_re= '[0-9A-Za-z]([-0-9A-Za-z]*[0-9A-Za-z])?';
$rfc1035_domain_re= "$rfc1035_label_re(\\.$rfc1035_label_re)*";
$rfc1035_domain_explain=
    "Each component must start with an alphanum, end with an alphanum and ".
    "contain\n only alphanums and hyphens.  Components must be separated ".
    "by full stops. ";

# Regexp for checking networks---this could probably be tightened up
$network_re= '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[0-9]{1,2}';

# Get hostname
chop($syshostname=`hostname --fqdn`);
$? && die "hostname --fqdn gave non-zero exit code $?   $syshostname\n";

if ($syshostname !~ m/^$rfc1035_domain_re$/) {
    print STDERR
	"Error: system's FQDN hostname ($syshostname) doesn't match\n".
	    "RFC1035 syntax; cannot configure the mail system.\n";
    exit(1);
}

# Read password file and find users that need redirection
open(P,"</etc/passwd") || die "cannot read /etc/passwd: $!\n";
@passwd1=@passwd2=<P>;
close(P);

@redirusers= grep(s/^([\w-]+):([^:]+):(\d+):\d+:.*\n/$1/ &&
                  length($2) < 13 && $3 < 100 && $1 ne "root", @passwd1);

$defaultpostmaster= (grep(s/^(\w+):([^:]+):(\d+):\d+:.*\n/$1/ &&
                          length($2) >= 13 && $3 >= 100, @passwd2))[0];

$redirinmessage= join(' ',@redirusers);
push(@redirusers,'nobody');
push(@redirusers,'');
$redirinalias= join(": root\n",@redirusers);

# Also need to redirect all these to postmaster; from rfc2142
@stdredirusers=('hostmaster','usenet','news','webmaster','www','ftp',
		'abuse','noc','security','');
$stdredirinalias= join(": root\n",@stdredirusers);


# Check for existing configuration
if ( -e "$etc/exim/exim.conf" ) {
  print "You already have an exim configuration. Continuing with eximconfig
will overwrite it. It will not keep any local modifications you have made.
If that is not your intention, you should break out now. If you do continue,
then your existing file will be renamed with .O on the end.
[---Press return---]";
}
else {
  print "I can do some automatic configuration of your mail system, by asking
you a number of questions.  Later you may have to confirm and/or correct
your answers. In any case, comprehensive information on configuring exim is
in the eximdoc package and in /usr/share/doc/exim/spec.txt
[---Press return---]";
}
<STDIN>;

# Loop forever until user is satisfied with their setup
for (;;) {

    undef @files;

# Which major configuration ?
    next unless &query(
"==============================================================================
You must choose one of the options below:

 (1) Internet site; mail is sent and received directly using SMTP. If your
     needs don't fit neatly into any category, you probably want to start
     with this one and then edit the config file by hand.

 (2) Internet site using smarthost: You receive Internet mail on this 
     machine, either directly by SMTP or by running a utility such as 
     fetchmail. Outgoing mail is sent using a smarthost. optionally with
     addresses rewritten. This is probably what you want for a dialup
     system.

 (3) Satellite system: All mail is sent to another machine, called a \"smart 
     host\" for delivery. root and postmaster mail is delivered according 
     to /etc/aliases. No mail is received locally.

 (4) Local delivery only: You are not on a network.  Mail for local users 
     is delivered.

 (5) No configuration: No configuration will be done now; your mail system 
     will be broken and should not be used. You must then do the 
     configuration yourself later or run this script, /usr/sbin/eximconfig, 
     as root. Look in /usr/share/doc/exim/example.conf.gz

Select a number from 1 to 5, from the list above.",
	   'configtype',
           -f '/usr/sbin/inetd' ? '1' : '4',
           'm/^[12345]$/');

# Exit if the user chose type 5
    if ($configtype == 5) {
        print "
==============================================================================
Mail configuration skipped.
WARNING: Do not start exim until you have configured it!
A bare bones configuration can be found in /usr/share/doc/exim/example.conf.gz

When you have configured it, running '/usr/sbin/eximconfig -i' will start exim.
\n";
        exit 0;
    }

# What are the hostnames for this system ?

    &query(
	$configtype == 3 ?
# Message used on satellite (type 3) systems
"==============================================================================
What is this system's name? It won't appear on From: lines of mail,
as rewriting is used" : 
# Message on other systems
"==============================================================================
What is the `visible' mail name of your system? This will appear on 
From: lines of outgoing messages.",
           'visiblename',
           $syshostname,
# Check against regexp
           'm/^$rfc1035_domain_re$/ ||
            &reswarn("This must conform to RFC1035\'s requirements.\n".
                     "$rfc1035_domain_explain")') || next if $configtype < 4;

# For local delivery only systems, visible name is hostname
    $visiblename = $syshostname if $configtype == 4;

# Store this visible name into /etc/mailname
    &setfileshort("mailname","$visiblename\n");
    
# Ask about other names to accept mail for, for internet sites
    @names = ( $visiblename, "localhost" ) ;
    @relay_names = () ;
    @relay_nets = () ;

    if( $configtype < 3 )
    {
	&query(
"==============================================================================
Does this system have any other names which may appear on incoming
mail messages, apart from the visible name above ($visiblename) and
localhost?

By default all domains will be treated the same; if you want different 
domain names to be treated differently, you will need to edit the config 
file afterwards: see the documentation for the \"domains\" director 
option.

If there are any more, enter them here, separated with spaces or commas.  
If there are none, say \`none'.",
	       'hostnames',
	       'none',
	       '1', 'e') || next ;

# Split entered string into array
	@names= split(/[ \t,]+/,$hostnames) ;

	$warnexh= 0;

# Check all names are valid domain names    
	grep(((m/^$rfc1035_domain_re$/ ||
	       ($warnexh= 1,
		(print STDERR "\n Warning - name \`$_' doesn't conform to ".
		          "RFC1035 requirements.")))),
	     @names);

	if ($warnexh) { print STDERR "\n$rfc1035_domain_explain\n"; }

# Shift visible name onto list of names
	unshift(@names, $visiblename);

# Shift "localhost" onto list of names
        unshift(@names, "localhost");

# Ask about domains to relay for
	&query(
"==============================================================================
All mail from here or specified other local machines to anywhere on
the internet will be accepted, as will mail from anywhere on the 
internet to here. 

Are there any domains you want to relay mail for---that is, you are 
prepared to accept mail for them from anywhere on the internet, but
they are not local domains.

If there are any, enter them here, separated with spaces or commas. You
can use wildcards. If there are none, say \`none'. If you want to relay 
mail for all domains that specify you as an MX, then say \`mx'",
	       'relaynames',
	       'none',
	       '1', 'e') || next ;

# Check for MX
	$relay_mx = 0 ;

	if( $relaynames eq "mx" )
	{
	    $relaynames = '' ;
	    $relay_mx = 1 ;
	}

# Split entered string into array
	@relay_names= split(/[ \t,]+/,$relaynames) ;
	
# Ask about networks we are a smarthost for
	&query(
"==============================================================================
Obviously, any machines that use us as a smarthost have to be excluded
from the relaying controls, as using us to relay mail for them is the
whole point.

Are there any networks of local machines you want to relay mail for?

If there are any, enter them here, separated with spaces or commas. You
should use the standard address/length format (e.g. 194.222.242.0/24)
If there are none, say \`none'.

You need to double the colons in IPv6 addreses (e.g. 5f03::1200::836f::::/48)",
	       'relaynets',
	       'none',
	       '1', 'e') || next ;

# Split entered string into array
	@relay_nets= split(/[ \t,]+/,$relaynets) ;
	
	$warnexh= 0;
	
# Check all names are valid networks    
	grep(((m/^$network_re$/ ||
	       ($warnexh= 1,
		(print STDERR "\n Warning - name \`$_' isn't a sensible".
		              " network name\n")))),
	     @relay_nets);

	if ($warnexh) { print STDERR "\n$rfc1035_domain_explain\n"; }
    }

# Options for satellite systems
    if ($configtype == 3) {
	
# Where should mail be addressed from
      RR:	&query(
"==============================================================================
Since this is going to be a satellite system, I need to know what domain
name to use for mail from local users; typically this is the machine on
which you normally receive your mail.

Where will your users read their mail?",
		       'readhost',
		       '',
		       '1', '') || next;
	
	if (!$readhost =~ m/^$rfc1035_domain_re$/) {
	    print STDERR "\n Warning - \`$1' does not conform to RFC1035";
	    print STDERR "\n$rfc1035_domain_explain\n";
	}
	
	if ($readhost eq $syshostname) {
	    print STDERR "\n This is a satellite system, specify a system\n";
	    print STDERR " other than $syshostname. \n\n";
	    goto RR;
	}

    }

# If we use a smarthost, what is it?
    if( $configtype == 2 || $configtype == 3 )
    {
      RS:	&query(
"==============================================================================
Which machine will act as the smarthost and handle outgoing mail?\n",
		       'smtphost',
		       $readhost,
		       '1', '') || next;
	
	if (!$smtphost =~ m/^$rfc1035_domain_re$/){
	    print STDERR "\n Warning - name \`$_' doesn't conform to RFC1035".
		" requirements.";
	    print STDERR "\n$rfc1035_domain_explain\n";
	}

	if ($smtphost eq $syshostname) {
	    print STDERR "\n That's silly. You can't send all mail back to\n";
	    print STDERR "yourself! \n\n";
	    goto RS;
	}
    }

    $colonhostnames= join(':',@names);
    $colonrelays= join(':',@relay_names);
    $colonrelaynets= join(':',@relay_nets);

# Who is to receive postmaster mail ?
    &query(
"==============================================================================
Mail for the \`postmaster' and \`root' accounts is usually redirected
to one or more user accounts, of the actual system administrators.
By default, I'll set things up so that mail for \`postmaster' and for
various system accounts is redirected to \`root', and mail for \`root'
is redirected to a real user.  This can be changed by editing /etc/aliases.

Note that postmaster-mail should usually be read on the system it is
directed to, rather than being forwarded elsewhere, so (at least one of)
the users you choose should not redirect their mail off this machine.

Which user account(s) should system administrator mail go to ?
Enter one or more usernames separated by spaces or commas .  Enter
\`none' if you want to leave this mail in \`root's mailbox - NB this
is strongly discouraged.  Also, note that usernames should be lowercase!",
           'postmasters',
           $defaultpostmaster,
           'm/^([-_a-z0-9]+[ \t,]*)*$/ ||
            &reswarn("\nUsernames must consist of lowercase alphanums, or - and _.\n")',
           'e') || next ;
    @postmasters= split(/[ \t,]+/,$postmasters);

# Output a description of the setup
    
    $confdescrip= 
"==============================================================================
Mail generated on this system will have \`".( $configtype == 3 ?
"$readhost" : "$visiblename"
)."' used
as the domain part (after the \@) in the From: field and similar places.
";
    $confdescrip.= "
The following domain(s) will be recognised as referring to this system:
 ".join(', ',@names)."\n";

    if( @relay_names != () )
    {
	$confdescrip.= "
Messages for the following domains will be relayed:
 ".join(', ',@relay_names)."\n" ;
    }

    if( $relay_mx )
    {
	$confdescrip.= "
\nMessages for all domains that we MX for will be relayed\n" ;
    }

    $confdescrip.="\nMail for postmaster, root, etc. will be sent to ".
	(@postmasters ? join(', ',@postmasters) : 'root').".\n";

    if ($configtype != 3){
	$confdescrip.= "\nLocal mail is delivered.\n";
    }
    else
    {
	$fuser = $postmasters[0];

	# Rewriting of mail for a satellite system
	@rewriters = ();

	for (@names){
	    
	    if( @postmasters )
	    {
		push(@rewriters,
		    "^(?i)(root|postmaster|mailer-daemon)\@$_ \$\{1\}\@in.limbo Ffr");
	    }	    
	    push(@rewriters,
		"*\@$_ \$\{1\}\@$readhost Ffr");
	}

	if( @postmasters )
	{
	    push(@rewriters,
	    	"*\@in.limbo $fuser\@$readhost Ffr");
	}

	$rewriters = join("\n", @rewriters);
	
	for (@postmasters) {
	    $_ = "real-$_" unless /@/;
	}
    }

    $rootalias= @postmasters ? "root: ".join(',',@postmasters)."\n" : '';

# Write aliases file

    $overwrite_aliases = 'y' ;
    if( -f "$etc/aliases" )
    {
	&query(
"==============================================================================
You already have an /etc/aliases file. Do you want to replace this with
a new one (the old one will be kept and renamed to aliases.O)? (y/n)",
	       'overwrite_aliases',
	       'y',
	       'm/^[yn]$/');
    }

    if( $overwrite_aliases eq 'y' )
    {
	&setfile('aliases',
'# This is the aliases file - it says who gets mail for whom.',"
postmaster: root
$rootalias
$redirinalias
$stdredirinalias
mailer-daemon: postmaster
");
    }
    else
    {
	print
"==============================================================================
Aliases file left as it was. The alias file that would have been
generated has been written to $etc/aliases.new. You might like to
check yours against it.\n" ;

	&setfile('aliases.new',
'# This is the aliases file - it says who gets mail for whom.',"

postmaster: root
$rootalias
$redirinalias
mailer-daemon: postmaster\n\n") ;
    }

###########################################################################
# START WRITING EXIM.CONF HERE
###########################################################################

    &setfile('exim/exim.conf',
'# This is the main exim configuration file.',
"
# Please see the manual for a complete list
# of all the runtime configuration options that can be included in a
# configuration file.

# This file is divided into several parts, all but the last of which are
# terminated by a line containing the word \"end\". The parts must appear
# in the correct order, and all must be present (even if some of them are
# in fact empty). Blank lines, and lines starting with # are ignored.

######################################################################
#                    MAIN CONFIGURATION SETTINGS                     #
######################################################################

# Specify the domain you want to be added to all unqualified addresses
# here. Unqualified addresses are accepted only from local callers by
# default. See the receiver_unqualified_{hosts,nets} options if you want
# to permit unqualified addresses from remote sources. If this option is
# not set, the primary_hostname value is used for qualification.

qualify_domain = $visiblename

# If you want unqualified recipient addresses to be qualified with a different
# domain to unqualified sender addresses, specify the recipient domain here.
# If this option is not set, the qualify_domain value is used.

# qualify_recipient =

# Specify your local domains as a colon-separated list here. If this option
# is not set (i.e. not mentioned in the configuration file), the
# qualify_recipient value is used as the only local domain. If you do not want
# to do any local deliveries, uncomment the following line, but do not supply
# any data for it. This sets local_domains to an empty string, which is not
# the same as not mentioning it at all. An empty string specifies that there
# are no local domains; not setting it at all causes the default value (the
# setting of qualify_recipient) to be used.

local_domains = $colonhostnames

# Allow mail addressed to our hostname, or to our IP address.

local_domains_include_host = true
local_domains_include_host_literals = true

# Domains we relay for; that is domains that aren't considered local but we 
# accept mail for them.

".
(@relay_names == () ? "#" : "" ).
"relay_domains = $colonrelays

# If this is uncommented, we accept and relay mail for all domains we are 
# in the DNS as an MX for.

".
($relay_mx == 1 ? "" : "#" ).
'relay_domains_include_local_mx = true

# No local deliveries will ever be run under the uids of these users (a colon-
# separated list). An attempt to do so gets changed so that it runs under the
# uid of "nobody" instead. This is a paranoic safety catch. Note the default
# setting means you cannot deliver mail addressed to root as if it were a
# normal user. This isn\'t usually a problem, as most sites have an alias for
# root that redirects such mail to a human administrator.
'.
($postmasters ? '
never_users = root' :'
# However, you chose not to have such an alias, so this is commented out

#never_users = root').'

# The setting below causes Exim to do a reverse DNS lookup on all incoming
# IP calls, in order to get the true host name. If you feel this is too
# expensive, you can specify the networks for which a lookup is done, or
# remove the setting entirely.

host_lookup = *

# The setting below would, if uncommented, cause Exim to check the syntax of
# all the headers that are supposed to contain email addresses (To:, From:,
# etc). This reduces the level of bounced bounces considerably.

# headers_check_syntax

# Exim contains support for the Realtime Blocking List (RBL), and the many
# similar services that are being maintained as part of the DNS. See 
# http://www.mail-abuse.org/ for background. The line below, if uncommented,
# will reject mail from hosts in the RBL, and add warning headers to mail
# from hosts in a list of dynamic-IP dialups. Note that MAPS may charge
# for this service.

#rbl_domains = rbl.mail-abuse.org/reject : dialups.mail-abuse.org/warn

# http://www.rfc-ignorant.org is another interesting site with a number of
# services you can use with the rbl_domains option
'.
( $colonrelaynets == '' ?
"
# The setting below allows your host to be used as a mail relay only by
# localhost: it locks out the use of your host as a mail relay by any
# other host. See the section of the manual entitled \"Control of relaying\" 
# for more info.

host_accept_relay = 127.0.0.1 : ::::1" :
"
# The setting below allows your host to be used as a mail relay by only
# the hosts in the specified networks. See the section of the manual
# entitled \"Control of relaying\" for more info.

host_accept_relay = 127.0.0.1 : ::::1 : $colonrelaynets" ).
'

# This setting allows anyone who has authenticated to use your host as a
# mail relay. To use this you will need to set up some authenticators at
# the end of the file

host_auth_accept_relay = *

# If you want Exim to support the "percent hack" for all your local domains,
# uncomment the following line. This is the feature by which mail addressed
# to x%y@z (where z is one of your local domains) is locally rerouted to
# x@y and sent on. Otherwise x%y is treated as an ordinary local part

# percent_hack_domains=*

# If this option is set, then any process that is running as one of the
# listed users may pass a message to Exim and specify the sender\'s
# address using the "-f" command line option, without Exim\'s adding a
# "Sender" header.

trusted_users = mail:uucp

# If this option is true, the SMTP command VRFY is supported on incoming
# SMTP connections; otherwise it is not.

'.($configtype == 1 ? "smtp_verify = true\n":"smtp_verify = false\n")
.'
# Some operating systems use the "gecos" field in the system password file
# to hold other information in addition to users\' real names. Exim looks up
# this field when it is creating "sender" and "from" headers. If these options
# are set, exim uses "gecos_pattern" to parse the gecos field, and then
# expands "gecos_name" as the user\'s name. $1 etc refer to sub-fields matched
# by the pattern.

gecos_pattern = ^([^,:]*)
gecos_name = $1

# This sets the maximum number of messages that will be accepted in one
# connection and immediately delivered. If one connection sends more
# messages than this, any further ones are accepted and queued but not
# delivered. The default is 10, which is probably enough for most purposes,
# but is too low on dialup SMTP systems, which often have many more mails
# queued for them when they connect.

smtp_accept_queue_per_connection = 100

# Send a mail to the postmaster when a message is frozen. There are many
# reasons this could happen; one is if exim cannot deliver a mail with no
# return address (normally a bounce) another that may be common on dialup
# systems is if a DNS lookup of a smarthost fails. Read the documentation
# for more details: you might like to look at the auto_thaw option

freeze_tell_mailmaster = true

# This string defines the contents of the \`Received\' message header that
# is added to each message, except for the timestamp, which is automatically
# added on at the end, preceded by a semicolon. The string is expanded each
# time it is used.

received_header_text = "Received: \
         ${if def:sender_rcvhost {from ${sender_rcvhost}\n\t}\
         {${if def:sender_ident {from ${sender_ident} }}\
         ${if def:sender_helo_name {(helo=${sender_helo_name})\n\t}}}}\
         by ${primary_hostname} \
         ${if def:received_protocol {with ${received_protocol}}} \
         (Exim ${version_number} #${compile_number} (Debian))\n\t\
         id ${message_id}\
         ${if def:received_for {\n\tfor <$received_for>}}"

# Attempt to verify recipient address before receiving mail, so that mails 
# to invalid addresses are rejected rather than accepted and then bounced. 
# Apparently some spammers are abusing servers that accept and then bounce
# to send bounces containing their spam to people.

receiver_try_verify = true

# This would make exim advertise the 8BIT-MIME option. According to
# RFC1652, this means it will take an 8bit message, and ensure it gets
# delivered correctly. exim won\'t do this: it is entirely 8bit clean
# but won\'t do any conversion if the next hop isn\'t. Therefore, if you
# set this option you are asking exim to lie and not be RFC
# compliant. But some people want it.

#accept_8bitmime = true

# This will cause it to accept mail only from the local interface

#local_interfaces = 127.0.0.1

# If this next line is uncommented, any user can see the mail queue
# by using the mailq command or exim -bp.

#queue_list_requires_admin = false

# The errors_copy line will cause the specified address to receive a copy
# of bounces generated on the system.

#errors_copy = *@* postmaster@yourdomain

# 
end


######################################################################
#                      TRANSPORTS CONFIGURATION                      #
######################################################################
#                       ORDER DOES NOT MATTER                        #
#     Only one appropriate transport is called for each delivery.    #
######################################################################

# This transport is used for local delivery to user mailboxes. On debian
# systems group mail is used so we can write to the /var/mail
# directory. (The alternative, which most other unixes use, is to deliver
# as the user\'s own group, into a sticky-bitted directory)

local_delivery:
  driver = appendfile
  group = mail
  mode = 0660
  mode_fail_narrower = false
  envelope_to_add = true
  return_path_add = true
  file = /var/mail/${local_part}

# This transport is used for handling pipe addresses generated by
# alias or .forward files. If the pipe generates any standard output,
# it is returned to the sender of the message as a delivery error. Set
# return_fail_output instead if you want this to happen only when the
# pipe fails to complete normally.

address_pipe:
  driver = pipe
  path = /usr/bin:/bin:/usr/local/bin
  return_fail_output

# This transport is used for handling file addresses generated by alias
# or .forward files.

address_file:
  driver = appendfile
  envelope_to_add = true
  return_path_add = true

# This transport is used for handling file addresses generated by alias
# or .forward files if the path ends in "/", which causes it to be treated
# as a directory name rather than a file name. Each message is then delivered
# to a unique file in the directory. If instead you want all such deliveries to
# be in the "maildir" format that is used by some other mail software,
# uncomment the final option below. If this is done, the directory specified
# in the .forward or alias file is the base maildir directory.
#
# Should you want to be able to specify either maildir or non-maildir
# directory-style deliveries, then you must set up yet another transport,
# called address_directory2. This is used if the path ends in "//" so should
# be the one used for maildir, as the double slash suggests another level
# of directory. In the absence of address_directory2, paths ending in //
# are passed to address_directory.

address_directory:
  driver = appendfile
  no_from_hack
  prefix = ""
  suffix = ""
# maildir_format

# This transport is used for handling autoreplies generated by the filtering
# option of the forwardfile director.

address_reply:
  driver = autoreply

# This transport is used for procmail

procmail_pipe:
  driver = pipe
  command = "/usr/bin/procmail"
  return_path_add
  delivery_date_add
  envelope_to_add
# check_string = "From "
# escape_string = ">From "
  suffix = ""

'. ($configtype < 4 ? 
'
# This transport is used for delivering messages over SMTP connections.

remote_smtp:
  driver = smtp
# authenticate_hosts = smarthost.isp.com

# To use SMTP AUTH when sending to a particular host, such as your ISP\'s
# smarthost, uncomment and edit the above line, and also the example
# client-side authenticators at the bottom of the file
':'').
'
end


######################################################################
#                      DIRECTORS CONFIGURATION                       #
#             Specifies how local addresses are handled              #
######################################################################
#                          ORDER DOES MATTER                         #
#   A local address is passed to each in turn until it is accepted.  #
######################################################################

# This allows local delivery to be forced, avoiding alias files and
# forwarding.

real_local:
  prefix = real-
  driver = localuser
  transport = local_delivery

# This director handles aliasing using a traditional /etc/aliases file.
# If any of your aliases expand to pipes or files, you will need to set
# up a user and a group for these deliveries to run under. You can do
# this by uncommenting the "user" option below (changing the user name
# as appropriate) and adding a "group" option if necessary.

system_aliases:
  driver = aliasfile
  file_transport = address_file
  pipe_transport = address_pipe
  file = /etc/aliases
  search_type = lsearch
# user = list
# Uncomment the above line if you are running smartlist

'. ($configtype == 3 ? "
# For a satellite sytem, all mail sent to local users is re-directed to 
# their accounts on $readhost

smart:
  driver = smartuser
  new_address = \$\{local_part\}\@$readhost
" : '
# This director handles forwarding using traditional .forward files.
# It also allows mail filtering when a forward file starts with the 
# string "# Exim filter": to disable filtering, uncomment the "filter" 
# option. The check_ancestor option means that if the forward file 
# generates an address that is an ancestor of the current one, the 
# current one gets passed on instead. This covers the case where A is 
# aliased to B and B has a .forward file pointing to A.

# For standard debian setup of one group per user, it is acceptable---normal
# even---for .forward to be group writable. If you have everyone in one
# group, you should comment out the "modemask" line. Without it, the exim
# default of 022 will apply, which is probably what you want.

userforward:
  driver = forwardfile
  file_transport = address_file
  pipe_transport = address_pipe
  reply_transport = address_reply
  no_verify
  check_ancestor
  check_local_user
  file = .forward
  modemask = 002
  filter

# This director runs procmail for users who have a .procmailrc file

procmail:
  driver = localuser
  transport = procmail_pipe
  require_files = ${local_part}:+${home}:+${home}/.procmailrc:+/usr/bin/procmail
  no_verify
    
# This director matches local user mailboxes.

localuser:
  driver = localuser
  transport = local_delivery
' ). '
end


######################################################################
#                      ROUTERS CONFIGURATION                         #
#            Specifies how remote addresses are handled              #
######################################################################
#                          ORDER DOES MATTER                         #
#  A remote address is passed to each in turn until it is accepted.  #
######################################################################

# Remote addresses are those with a domain that does not match any item
# in the "local_domains" setting above.
'
. ($configtype == 1 ? '
# This router routes to remote hosts over SMTP using a DNS lookup with
# default options.

lookuphost:
  driver = lookuphost
  transport = remote_smtp

# This router routes to remote hosts over SMTP by explicit IP address,
# given as a "domain literal" in the form [nnn.nnn.nnn.nnn]. The RFCs
# require this facility, which is why it is enabled by default in Exim.
# If you want to lock it out, set forbid_domain_literals in the main
# configuration section above.

literal:
  driver = ipliteral
  transport = remote_smtp
':'').
 ($configtype == 2 || $configtype == 3 ? "
# Send all mail to a smarthost

smarthost:
  driver = domainlist
  transport = remote_smtp
  route_list = \"* $smtphost bydns_a\"
":'').
 ($configtype == 4 ? '
# Stand-alone system, so no routers configured.

':'').
'
end


######################################################################
#                      RETRY CONFIGURATION                           #
######################################################################

# This single retry rule applies to all domains and all errors. It specifies
# retries every 15 minutes for 2 hours, then increasing retry intervals,
# starting at 2 hours and increasing each time by a factor of 1.5, up to 16
# hours, then retries every 8 hours until 4 days have passed since the first
# failed delivery.

# Domain               Error       Retries
# ------               -----       -------

*                      *           F,2h,15m; G,16h,2h,1.5; F,10d,8h

end


######################################################################
#                      REWRITE CONFIGURATION                         #
######################################################################

# This rewriting rule is particularly useful for dialup users who
# don\'t have their own domain, but could be useful for anyone.
# It looks up the real address of all local users in a file

*@'. lc($visiblename) .
'    ${lookup{$1}lsearch{/etc/email-addresses}\
						{$value}fail} frFs
'
. ( $configtype == 3 ? "

# These rewriters make sure the mail messages appear to have originated
# from the real mail-reading host.

$rewriters

" : "").
'

end

######################################################################
#                   AUTHENTICATION CONFIGURATION                     #
######################################################################

# Look in the documentation (in package exim-doc or exim-doc-html for 
# information on how to set up authenticated connections.

# The examples below are for server side authentication; they allow two 
# styles of plain-text authentication against an /etc/exim/passwd file 
# which should have user IDs in the first column and crypted passwords 
# in the second.

# plain:
#   driver = plaintext
#   public_name = PLAIN
#   server_condition = "${if crypteq{$3}{${extract{1}{:}{${lookup{$2}lsearch{/etc/exim/passwd}{$value}{*:*}}}}}{1}{0}}"
#   server_set_id = $2
#
# login:
#   driver = plaintext
#   public_name = LOGIN
#   server_prompts = "Username:: : Password::"
#   server_condition = "${if crypteq{$2}{${extract{1}{:}{${lookup{$1}lsearch{/etc/exim/passwd}{$value}{*:*}}}}}{1}{0}}"
#   server_set_id = $1

# These examples below are the equivalent for client side authentication. 
# They assume that you only use client side authentication to connect to 
# one host (such as a smarthost at your ISP), or else use the same user 
# name and password everywhere

# plain:
#   driver = plaintext
#   public_name = PLAIN
#   client_send = "^username^password"
#
# login:
#   driver = plaintext
#   public_name = LOGIN
#   client_send = ": username : password"
#
# cram_md5:
#   driver = cram_md5
#   public_name = CRAM-MD5
#   client_name = username
#   client_secret = password

# End of Exim configuration file
' );

# Finished writing configuration file

# Add routing information to descriptions
    if ($configtype == 1){
	$confdescrip .= "
Outbound remote mail is looked up in the Internet DNS, and delivered
using that data if any is found; otherwise such messages are bounced.
";
    }

    if ($configtype == 2){
        $confdescrip .= "
Outbound remote mail is sent via $smtphost.
";
    }

    if ($configtype == 3){
	$confdescrip .= "
All mail is being routed and delivered via $smtphost.
";
    }

    if ($configtype == 4){
	$condescrip .= "Any mail destined for remote addresses is bounced.";
    }

# Print description of behaviour
    do {
        print "\n\nThe following configuration has been entered:

$confdescrip

Note that you can set email addresses used for outgoing mail by editing
/etc/email-addresses.

Is this OK ?  Hit Return or type \`y' to confirm it and install,
or \`n' to make changes (in which case we'll go round again, giving you
your previous answers as defaults.     (Y/n) ";

	$!=0; defined($what=<STDIN>) || die "smailconfig: EOF/error on stdin: $!\n";
    } while ($what !~ m/^\s*[yn]?\s*$/i);

# Finish if it's OK
    last unless $what =~ m/^n/i;
}

# Subroutine to set a file without a header
#
# setfileshort( filename, text )
#
sub setfileshort {
    local ($filename,$value) = @_;
    push(@files,$filename);
    $filecontents{$filename}= $value;
}

# Subroutine to set a file with a standard header
#
# setfile( filename, description, text )
#
# File consists of description, standard header, then text.
#
sub setfile {
    local ($filename,$value1,$value2,$d) = @_;
    chop($d=`date`);
    $v=
"$value1\
# It was originally generated by `eximconfig', part of the exim package
# distributed with Debian, but it may edited by the mail system administrator.
# This file originally generated by eximconfig at $d
# See exim info section for details of the things that can be configured here.
$value2";
    push(@files,$filename);
    $filecontents{$filename}=$v;
}

# Subroutine to print warning
#
sub reswarn {
    print STDERR "$_[0]\n";
    return 0;
}

# Subroutine to ask user for information
#
# query( question, varname, default, check, opts )
#
# Question is used as a prompt, default is the default; the user's 
# answer is tested using a check routine or expression and if valid
# is stored in the variable named by varname. opts can set various
# options, currently only allowing "none" as a response
#
sub query {
    local ($question, $varname, $default, $check, $opts) = @_;
    local ($allowempty, $response, $e);
    print "\n";
    $allowempty= $opts =~ m/e/;
    if (eval "defined(\$$varname)") {
        $default= eval "\$$varname";
        $default='none' if $default eq '' && $allowempty;
    }
    for (;;) {
        print "$question\nEnter value (";
        print "default=\`$default', " if length($default);
        print "\`x' to restart): ";
	$!=0; defined($iread=<STDIN>) || die "smailconfig: EOF/error on stdin: $!\n";
        $_= $iread; s/^\s+//; s/\s+$//;
        return 0 if m/^x$/i;
        $_= $default if $_ eq '';
        if (!length($_)) {
            print "  Sorry, you must enter a value.\n";
            next;
        }
        $_= '' if $_ eq 'none' && $allowempty;
        $response= $_;
        last if eval $check;
        if (length($@)) {
            print STDERR "  Aargh, bug - bug - please report:\n$@\nin\n $check\n";
            last;
        } else {
            print "  Sorry, that value is not acceptable.\n";
        }
    }
    $e= "\$$varname = \$response;";
    eval $e; length($@) && die "aargh - internal error ($e): $@";
    1;
}

# Write out new versions of all files that have been set

for $f (@files) {
    open(N,">$etc/$f.postinstnew") || die "Error creating $etc/$f.postinstnew: $!\n";
    print(N $filecontents{$f}) || die "Error writing $etc/$f.postinstnew: $!\n";
    close(N) || die "Error closing $etc/$f.postinstnew: $!\n";
}

# Keep old versions of files that have been set by renaming them to .O

while (defined($f= pop(@files))) {
    if ( "$f" ne "aliases.new" && -f "$etc/$f") {
	print "\nKeeping previous $etc/$f as $etc/$f.O\n";
	rename("$etc/$f", "$etc/$f.O") || die "Error renaming original $etc/$f: $!\n";
    }
    rename("$etc/$f.postinstnew","$etc/$f") || die "Error installing $etc/$f: $!\n";
}

print "
Configuration installed.

";

# That's all