aboutsummaryrefslogtreecommitdiff
path: root/mail/qmail/files/qmailsend.in
blob: 9958ae6fe30e1e70e08f4f7305bfe91c78a26646 (plain) (blame)
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
#!/bin/sh

# PROVIDE: qmailsend
# REQUIRE: network
#
# The wrapper around qmail's qmail-send, qmail-lspawn, qmail-rspawn and
# qmail-clean chain.
#
# the qmailsend_delivery variable controls where mails should be delivered to:
#  maildir - qmail-local to ~/Maildir/ (this is the default)
#  mailbox - qmail-local to ~/Mailbox
#  proc    - procmail to /var/spool/mail/$USER
#  V7      - /bin/mail V7 interface to /var/spool/mail/$USER
#  SVR4    - /bin/mail SVR4 interface to /var/spool/mail/$USER
#  BSD44   - /usr/libexec/mail.local to /var/spool/mail/$USER
#
# Setting qmailsend_dotforward enables support for sendmail style
# .forward files
#

. /etc/rc.subr

name=qmailsend
rcvar=qmailsend_enable

load_rc_config $name

: ${qmailsend_delivery="maildir"}
: ${qmailsend_dotforward="NO"}

start_cmd="${name}_start"
command="%%PREFIX%%/bin/qmail-start"
procname=qmail-send

extra_commands="flush"
flush_cmd="qmailsend_flush"

pidfile="/var/run/${name}.pid"

qmailsend_start() {
  case ${qmailsend_delivery} in
    maildir) command_args=./Maildir/;;
    mailbox) command_args=./Mailbox;;
    proc)    command_args='|preline procmail';;
    V7)      command_args='|preline -f /bin/mail -f "${SENDER:-MAILER-DAEMON}" -d "$USER"';;
    SVR4)    command_args='|preline -f /bin/mail -r "${SENDER:-MAILER-DAEMON}" -d "$USER"';;
    BSD44)   command_args='|preline -f /usr/libexec/mail.local -r "${SENDER:-MAILER-DAEMON}" -d "$USER"';;
    *)       err 1 "Error: Unknown qmailsend delivery method: ${qmailsend_delivery}";;
  esac
  if checkyesno qmailsend_dotforward; then
    command_args='|dot-forward .forward
'"${command_args}"
  fi

  exec env - PATH="%%PREFIX%%/bin:%%LOCALBASE%%/bin:$PATH" ${command} "${command_args}" splogger qmail&
  /bin/pgrep -P $$ > ${pidfile}
}

qmailsend_flush() {
  /bin/pkill -ALRM ${rc_pid}
}

run_rc_command "$1"