-
Notifications
You must be signed in to change notification settings - Fork 2
/
msmtpqw
executable file
·80 lines (66 loc) · 1.3 KB
/
msmtpqw
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
#!/bin/sh
#
# Replacement for msmtpq.
#
# TODO(d630): finish script
Q=${XDG_VAR_HOME:?}/mail/queue \
LOG=${XDG_VAR_HOME}/log/msmtp-queue.log \
EMAIL_CONN_TEST=P
export Q
export LOG
export EMAIL_CONN_TEST
exec msmtpq "$@"
__msmpt() { IFS=" " command msmpt $*; }
lock_queue() {
builtin typeset lock_file=${queue_dir}/.lock
builtin typeset -i \
lock_status= \
sec_max=240 \
SECONDS=
function make_lock
{
command mkdir "$lock_file"
}
if
[[ $1 == -u ]]
then
command rm -r "$lock_file"
else
make_lock && lock_status+=1
while
command sleep 0.5 && ( (
lock_status == 0 ||
SECONDS <= sec_max
))
do
make_lock && lock_status+=1
done
( (lock_status == 0)) && {
echo fail:
}
fi
builtin unset -f make_lock
}
make_id() {
id=$(command date +%Y-%m-%d-%H.%M.%S)-${RANDOM}${RANDOM}${RANDOM}${RANDOM}${RANDOM}${RANDOM}
fqp=${queue_dir}/${id}
}
send_mail() {
[[ $EMAIL_CONN_TEST != x ]] && connect_test || {
echo fail:
}
if
__msmpt "$@" <"${fqp}.mail" 1>/dev/null
then
:
else
:
fi
}
connect_test() {
:
}
lock_queue() {
:
}
# vim: set ft=sh :