File: set_sendmail.conf

package info (click to toggle)
msmtp 1.4.28-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,980 kB
  • sloc: ansic: 10,847; sh: 5,168; python: 121; makefile: 84; sed: 16
file content (74 lines) | stat: -rw-r--r-- 2,556 bytes parent folder | download | duplicates (10)
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
# Default setting used if the domain name can not be found, or if something goes
# wrong.
#default='/usr/sbin/sendmail -oem -oi'

# Make matching case insensitive
shopt -s nocasematch

# Regexp matching the host name of the machine this script should run on. (Other
# machines get the default above).
run_hosts='^baradur|mordor$'

# The file /etc/resolv.conf is egrepped against patterns in the array
# "resolv_regexp" (A leading "!" denotes negation of match). If a match is found
# the corresponding msmtp account (from the accounts array) is used.
#
# If no match is found, then this script gets the domain name. This could be
# time consuming if it is not found in /etc/resolv.conf, as it involves a name
# server lookup. The domain name is then matched against the (bash) regexp's in
# the array "dom_regexp". If a match is found, the corresponding msmtp account
# (from the accounts array) is used. 
#
# Patterns are matched in the order they are defined. If no pattern matches,
# then the script produces no output.
#
# An account named "ssh" is special. It calls the function ssh_tunnel when such
# an account is selected.
#
# The following are the settings I use on my laptop.


# Use default account if we could not get the domain name.
accounts+=(default)
dom_regexp+=('^$')
resolv_regexp+=('!nameserver')

# Use account 'stanford' from within the Stanford.EDU domain.
accounts+=(stanford)
#dom_regexp+=('^(Stanford\.EDU|gi1242.net)$')
dom_regexp+=('^Stanford\.EDU$')
resolv_regexp+=('^(nameserver[[:space:]]+171\.64\.7\.|search.*[[:space:]]stanford.edu)')

# ri.cox.net seems to have firewalled port 25, so use ssh tunnelling in this
# domain. (The function ssh_tunnel (called automatically) sets up the tunnel)
accounts+=(ssh)
dom_regexp+=('(^|\.)(ri\.cox\.net|near.uiuc.edu)$')
resolv_regexp+=('')

# From outside the Stanford.EDU domain, use account 'roam' with Kerberos
# authentication. It involves typing my password once a day (when my kerberos
# tickets expire), but is faster than ssh tunneling. (This requires traffic
# through port 25 to not be firewalled)
accounts+=(roam)
dom_regexp+=('.')
resolv_regexp+=('')

# Ignore case while matching.
shopt -s nocasematch

# Function called when account named "ssh" is used
function ssh_tunnel()
{
    debug "Starting SSH tunnel"
    # Kill an already running tunnel (connection might be inactive)
    pkill -f '^ssh.*8025:math:25'

    # Create a tunnel to mail server. Forward local port 8025 to remote 25
    ssh -N -f -L 8025:math:25 math &
}

#
# End user settings
#

# vim: set ft=sh: