2 URI_ENCODE
="`dirname $0`/uri-encode"
5 # linux file utility needs -L option to resolve symlinks
6 if [ "`uname -s`" = "Linux" ]
11 # do not confuse the system mail clients with OOo and Java libraries
14 # tries to locate the executable specified
15 # as first parameter in the user's path.
17 if [ ! -z "$1" ]; then
18 for i
in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
19 if [ -x "$i/$1" -a ! -d "$i/$1" ]; then
27 # checks for the original mozilla start script(s)
28 # and restrict the "-remote" semantics to those.
30 # find mozilla script in PATH if necessary
31 if [ "`basename $1`" = "$1" ]; then
37 if file $FOPTS "$moz" |
grep "script" > /dev
/null
&& grep "[NM]PL" "$moz" > /dev
/null
; then
38 "$moz" -remote 'ping()' 2>/dev
/null
>/dev
/null
42 "$1" -remote "xfeDoCommand(composeMessage,$2)" &
49 if [ "$1" = "--mailclient" ]; then
55 # autodetect mail client from executable name
56 case `basename "$MAILER" | sed 's/-.*$//'` in
58 iceape | mozilla | netscape | seamonkey | icedove | thunderbird
)
60 while [ "$1" != "" ]; do
71 BCC
=${BCC:-}${BCC:+,}$2
83 ATTACH
=${ATTACH:-}${ATTACH:+,}`echo "file://$2" | ${URI_ENCODE}`
92 if [ "$TO" != "" ]; then
93 COMMAND=${COMMAND:-}${COMMAND:+,}to=${TO}
95 if [ "$CC" != "" ]; then
96 COMMAND=${COMMAND:-}${COMMAND:+,}cc=${CC}
98 if [ "$BCC" != "" ]; then
99 COMMAND=${COMMAND:-}${COMMAND:+,}bcc=${BCC}
101 if [ "$SUBJECT" != "" ]; then
102 COMMAND=${COMMAND:-}${COMMAND:+,}subject=${SUBJECT}
104 if [ "$BODY" != "" ]; then
105 COMMAND=${COMMAND:-}${COMMAND:+,}body=${BODY}
107 if [ "$ATTACH" != "" ]; then
108 COMMAND=${COMMAND:-}${COMMAND:+,}attachment=${ATTACH}
111 run_mozilla "$MAILER" "$COMMAND"
116 while [ "$1" != "" ]; do
119 TO="${TO:-}${TO:+,}$2"
123 CC="${CC:-}${CC:+,}$2"
127 BCC="${BCC:-}${BCC:+,}$2"
148 ${MAILER} --composer ${CC:+--cc} ${CC:+"${CC}"} ${BCC:+--bcc} ${BCC:+"${BCC}"} \
149 ${SUBJECT:+--subject} ${SUBJECT:+"${SUBJECT}"} ${BODY:+--body} ${BODY:+"${BODY}"} \
150 ${ATTACH:+--attach} ${ATTACH:+"${ATTACH}"} ${TO:+"${TO}"}
155 while [ "$1" != "" ]; do
162 TO="${TO:-}${TO:+,}$2"
166 CC="${CC:-}${CC:+,}$2"
170 BCC="${BCC:-}${BCC:+,}$2"
178 TEMPLATE="`basename $0`.mutt.XXXXXXXX"
179 BODY=`mktemp
-q -t ${TEMPLATE}`
193 x-terminal-emulator -e ${MAILER} \
194 ${FROM:+-e} ${FROM:+"set from=\"${FROM}\""} \
195 ${CC:+-c} ${CC:+"${CC}"} \
196 ${BCC:+-b} ${BCC:+"${BCC}"} \
197 ${SUBJECT:+-s} ${SUBJECT:+"${SUBJECT}"} \
198 ${BODY:+-i} ${BODY:+"${BODY}"} \
199 ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"} \
206 while [ "$1" != "" ]; do
209 if [ "${TO}" != "" ]; then
210 MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
217 MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | ${URI_ENCODE}`
221 MAILTO
="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | ${URI_ENCODE}`
225 MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | ${URI_ENCODE}`
229 MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | ${URI_ENCODE}`
233 MAILTO
="${MAILTO:-}${MAILTO:+&}attach="`echo "file://$2" | ${URI_ENCODE}`
242 MAILTO="mailto
:${TO}?
${MAILTO}"
243 ${MAILER} "${MAILTO}" &
248 while [ "$1" != "" ]; do
251 if [ "${TO}" != "" ]; then
252 MAILTO="${MAILTO:-}${MAILTO:+&}to
=$2"
259 MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | ${URI_ENCODE}`
263 MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | ${URI_ENCODE}`
267 MAILTO
="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | ${URI_ENCODE}`
271 MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | ${URI_ENCODE}`
275 MAILTO="${MAILTO:-}${MAILTO:+&}attachment="`echo "file://$2" | ${URI_ENCODE}`
284 MAILTO
="mailto:${TO}?${MAILTO}"
285 ${MAILER} "${MAILTO}" &
290 while [ "$1" != "" ]; do
306 ${MAILER} ${TO:+-T} ${TO:-} ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"}
311 while [ "$1" != "" ]; do
318 ATTACH
="${ATTACH:-}${ATTACH:+ }$2"
327 ${MAILER} ${TO:+--compose} "${TO:-}" ${ATTACH:+--attach} "${ATTACH:-}"
330 Mail | Thunderbird | *.app )
332 while [ "$1" != "" ]; do
335 #i95688# fix filenames containing accented chars, whatever alien
336 ATTACH="${ATTACH:-}${ATTACH:+ }"`echo "file://$2" | ${URI_ENCODE}`
344 /usr/bin/open -a "${MAILER}" ${ATTACH}
349 # DESKTOP_LAUNCH, see http://freedesktop.org/pipermail/xdg/2004-August/004489.html
350 if [ -n "$DESKTOP_LAUNCH" ]; then
351 while [ "$1" != "" ]; do
354 if [ "${TO}" != "" ]; then
355 MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
362 MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | ${URI_ENCODE}`
366 MAILTO
="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | ${URI_ENCODE}`
370 MAILTO="${MAILTO:-}${MAILTO:+&}subject="`echo "$2" | ${URI_ENCODE}`
374 MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | ${URI_ENCODE}`
378 MAILTO
="${MAILTO:-}${MAILTO:+&}attachment="`echo "$2" | ${URI_ENCODE}`
387 MAILTO="mailto
:${TO}?
${MAILTO}"
388 ${DESKTOP_LAUNCH} "${MAILTO}" &
390 echo "Could not determine a
mail client to use.
"
396 echo "Unsupported
mail client
: `basename $MAILER | sed 's/-.*^//'`"