xref: /trunk/main/shell/source/unix/misc/senddoc.sh (revision 14c7d0b5)
1cdf0e10cSrcweir#!/bin/sh
29f22d7c2SAndrew Rist# *************************************************************
3*14c7d0b5Smseidel#
49f22d7c2SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
59f22d7c2SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
69f22d7c2SAndrew Rist#  distributed with this work for additional information
79f22d7c2SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
89f22d7c2SAndrew Rist#  to you under the Apache License, Version 2.0 (the
99f22d7c2SAndrew Rist#  "License"); you may not use this file except in compliance
109f22d7c2SAndrew Rist#  with the License.  You may obtain a copy of the License at
11*14c7d0b5Smseidel#
129f22d7c2SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
13*14c7d0b5Smseidel#
149f22d7c2SAndrew Rist#  Unless required by applicable law or agreed to in writing,
159f22d7c2SAndrew Rist#  software distributed under the License is distributed on an
169f22d7c2SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
179f22d7c2SAndrew Rist#  KIND, either express or implied.  See the License for the
189f22d7c2SAndrew Rist#  specific language governing permissions and limitations
199f22d7c2SAndrew Rist#  under the License.
20*14c7d0b5Smseidel#
219f22d7c2SAndrew Rist# *************************************************************
22ba2c76b2SAriel Constenla-HaileURI_ENCODE="`dirname "$0"`/uri-encode"
23cdf0e10cSrcweirFOPTS=""
24cdf0e10cSrcweir
25*14c7d0b5Smseidel# Linux file utility needs -L option to resolve symlinks
26cdf0e10cSrcweirif [ "`uname -s`" = "Linux" ]
27cdf0e10cSrcweirthen
28cdf0e10cSrcweir  FOPTS="-L"
29cdf0e10cSrcweirfi
30cdf0e10cSrcweir
31*14c7d0b5Smseidel# do not confuse the system mail clients with AOO and Java libraries
32cdf0e10cSrcweirunset LD_LIBRARY_PATH
33cdf0e10cSrcweir
34*14c7d0b5Smseidel# tries to locate the executable specified
35cdf0e10cSrcweir# as first parameter in the user's path.
36cdf0e10cSrcweirwhich() {
37cdf0e10cSrcweir	if [ ! -z "$1" ]; then
38cdf0e10cSrcweir		for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
39cdf0e10cSrcweir			if [ -x "$i/$1" -a ! -d "$i/$1" ]; then
40cdf0e10cSrcweir				echo "$i/$1"
41cdf0e10cSrcweir				break;
42cdf0e10cSrcweir			fi
43cdf0e10cSrcweir		done
44cdf0e10cSrcweir	fi
45cdf0e10cSrcweir}
46cdf0e10cSrcweir
47*14c7d0b5Smseidel# checks for the original Mozilla start script(s)
48cdf0e10cSrcweir# and restrict the "-remote" semantics to those.
49cdf0e10cSrcweirrun_mozilla() {
50cdf0e10cSrcweir	# find mozilla script in PATH if necessary
51cdf0e10cSrcweir	if [ "`basename $1`" = "$1" ]; then
52cdf0e10cSrcweir		moz=`which $1`
53cdf0e10cSrcweir	else
54cdf0e10cSrcweir		moz=$1
55cdf0e10cSrcweir	fi
56cdf0e10cSrcweir
57cdf0e10cSrcweir	if file $FOPTS "$moz" | grep "script" > /dev/null && grep "[NM]PL" "$moz" > /dev/null; then
58cdf0e10cSrcweir		"$moz" -remote 'ping()' 2>/dev/null >/dev/null
59cdf0e10cSrcweir		if [ $? -eq 2 ]; then
60cdf0e10cSrcweir			"$1" -compose "$2" &
61cdf0e10cSrcweir		else
62cdf0e10cSrcweir			"$1" -remote "xfeDoCommand(composeMessage,$2)" &
63cdf0e10cSrcweir		fi
64cdf0e10cSrcweir	else
65cdf0e10cSrcweir		"$1" -compose "$2" &
66cdf0e10cSrcweir	fi
67cdf0e10cSrcweir}
68cdf0e10cSrcweir
69cdf0e10cSrcweirif [ "$1" = "--mailclient" ]; then
70cdf0e10cSrcweir	shift
71cdf0e10cSrcweir	MAILER=$1
72cdf0e10cSrcweir	shift
73cdf0e10cSrcweirfi
74cdf0e10cSrcweir
75cdf0e10cSrcweir# autodetect mail client from executable name
76cdf0e10cSrcweircase `basename "$MAILER" | sed 's/-.*$//'` in
77cdf0e10cSrcweir
78cdf0e10cSrcweir	iceape | mozilla | netscape | seamonkey | icedove | thunderbird)
79*14c7d0b5Smseidel
80cdf0e10cSrcweir		while [ "$1" != "" ]; do
81cdf0e10cSrcweir			case $1 in
82cdf0e10cSrcweir				--to)
83cdf0e10cSrcweir					TO=${TO:-}${TO:+,}$2
84cdf0e10cSrcweir					shift
85cdf0e10cSrcweir					;;
86cdf0e10cSrcweir				--cc)
87cdf0e10cSrcweir					CC=${CC:-}${CC:+,}$2
88cdf0e10cSrcweir					shift
89cdf0e10cSrcweir					;;
90cdf0e10cSrcweir				--bcc)
91cdf0e10cSrcweir					BCC=${BCC:-}${BCC:+,}$2
92cdf0e10cSrcweir					shift
93cdf0e10cSrcweir					;;
94cdf0e10cSrcweir				--subject)
95cdf0e10cSrcweir					SUBJECT=$2
96cdf0e10cSrcweir					shift
97cdf0e10cSrcweir					;;
98cdf0e10cSrcweir				--body)
99cdf0e10cSrcweir					BODY=$2
100cdf0e10cSrcweir					shift
101cdf0e10cSrcweir					;;
102cdf0e10cSrcweir				--attach)
103ba2c76b2SAriel Constenla-Haile					ATTACH=${ATTACH:-}${ATTACH:+,}`echo "file://$2" | "${URI_ENCODE}"`
104cdf0e10cSrcweir					shift
105cdf0e10cSrcweir					;;
106cdf0e10cSrcweir				*)
107cdf0e10cSrcweir					;;
108cdf0e10cSrcweir			esac
109cdf0e10cSrcweir			shift;
110cdf0e10cSrcweir		done
111cdf0e10cSrcweir
112cdf0e10cSrcweir		if [ "$TO" != "" ]; then
1137aca818aSAriel Constenla-Haile			COMMAND=${COMMAND:-}${COMMAND:+,}to=\'${TO}\'
114cdf0e10cSrcweir		fi
115cdf0e10cSrcweir		if [ "$CC" != "" ]; then
1167aca818aSAriel Constenla-Haile			COMMAND=${COMMAND:-}${COMMAND:+,}cc=\'${CC}\'
117cdf0e10cSrcweir		fi
118cdf0e10cSrcweir		if [ "$BCC" != "" ]; then
1197aca818aSAriel Constenla-Haile			COMMAND=${COMMAND:-}${COMMAND:+,}bcc=\'${BCC}\'
120cdf0e10cSrcweir		fi
121cdf0e10cSrcweir		if [ "$SUBJECT" != "" ]; then
1227aca818aSAriel Constenla-Haile			COMMAND=${COMMAND:-}${COMMAND:+,}subject=\'${SUBJECT}\'
123cdf0e10cSrcweir		fi
124cdf0e10cSrcweir		if [ "$BODY" != "" ]; then
1257aca818aSAriel Constenla-Haile			COMMAND=${COMMAND:-}${COMMAND:+,}body=\'${BODY}\'
126cdf0e10cSrcweir		fi
127cdf0e10cSrcweir		if [ "$ATTACH" != "" ]; then
1287aca818aSAriel Constenla-Haile			COMMAND=${COMMAND:-}${COMMAND:+,}attachment=\'${ATTACH}\'
129cdf0e10cSrcweir		fi
130*14c7d0b5Smseidel
131cdf0e10cSrcweir		run_mozilla "$MAILER" "$COMMAND"
132cdf0e10cSrcweir		;;
133*14c7d0b5Smseidel
134*14c7d0b5Smseidel	kmail)
135*14c7d0b5Smseidel
136*14c7d0b5Smseidel		while [ "$1" != "" ]; do
137*14c7d0b5Smseidel			case $1 in
138*14c7d0b5Smseidel				--to)
139*14c7d0b5Smseidel					TO="${TO:-}${TO:+,}$2"
140*14c7d0b5Smseidel					shift
141*14c7d0b5Smseidel					;;
142*14c7d0b5Smseidel				--cc)
143*14c7d0b5Smseidel					CC="${CC:-}${CC:+,}$2"
144*14c7d0b5Smseidel					shift
145*14c7d0b5Smseidel					;;
146*14c7d0b5Smseidel				--bcc)
147*14c7d0b5Smseidel					BCC="${BCC:-}${BCC:+,}$2"
148*14c7d0b5Smseidel					shift
149*14c7d0b5Smseidel					;;
150*14c7d0b5Smseidel				--subject)
151*14c7d0b5Smseidel					SUBJECT="$2"
152*14c7d0b5Smseidel					shift
153*14c7d0b5Smseidel					;;
154*14c7d0b5Smseidel				--body)
155*14c7d0b5Smseidel					BODY="$2"
156*14c7d0b5Smseidel					shift
157*14c7d0b5Smseidel					;;
158*14c7d0b5Smseidel				--from)
159*14c7d0b5Smseidel					FROM="$2"
160*14c7d0b5Smseidel					shift
161*14c7d0b5Smseidel					;;
162*14c7d0b5Smseidel				--attach)
163*14c7d0b5Smseidel					ATTACH="${ATTACH:-}${ATTACH:+ }--attach "`echo "file://$2" | "${URI_ENCODE}"`
164*14c7d0b5Smseidel					shift
165*14c7d0b5Smseidel					;;
166*14c7d0b5Smseidel				*)
167*14c7d0b5Smseidel					;;
168*14c7d0b5Smseidel			esac
169*14c7d0b5Smseidel			shift;
170*14c7d0b5Smseidel		done
171*14c7d0b5Smseidel
172*14c7d0b5Smseidel		${MAILER} --composer \
173*14c7d0b5Smseidel			${CC:+--cc} ${CC:+"${CC}"} \
174*14c7d0b5Smseidel			${BCC:+--bcc} ${BCC:+"${BCC}"} \
175*14c7d0b5Smseidel			${SUBJECT:+--subject} ${SUBJECT:+"${SUBJECT}"} \
176*14c7d0b5Smseidel			${BODY:+--body} ${BODY:+"${BODY}"} \
177*14c7d0b5Smseidel			${FROM:+--header} ${FROM:+"From: ${FROM}"} \
178*14c7d0b5Smseidel			${ATTACH:+${ATTACH}} \
179*14c7d0b5Smseidel			${TO:+"${TO}"}
180*14c7d0b5Smseidel		;;
181*14c7d0b5Smseidel
182cdf0e10cSrcweir	mutt)
183*14c7d0b5Smseidel
184cdf0e10cSrcweir		while [ "$1" != "" ]; do
185cdf0e10cSrcweir			case $1 in
186cdf0e10cSrcweir				--from)
187cdf0e10cSrcweir					FROM="$2"
188cdf0e10cSrcweir					shift
189cdf0e10cSrcweir					;;
190cdf0e10cSrcweir				--to)
191cdf0e10cSrcweir					TO="${TO:-}${TO:+,}$2"
192cdf0e10cSrcweir					shift
193cdf0e10cSrcweir					;;
194cdf0e10cSrcweir				--cc)
195cdf0e10cSrcweir					CC="${CC:-}${CC:+,}$2"
196cdf0e10cSrcweir					shift
197cdf0e10cSrcweir					;;
198cdf0e10cSrcweir				--bcc)
199cdf0e10cSrcweir					BCC="${BCC:-}${BCC:+,}$2"
200cdf0e10cSrcweir					shift
201cdf0e10cSrcweir					;;
202cdf0e10cSrcweir				--subject)
203cdf0e10cSrcweir					SUBJECT="$2"
204cdf0e10cSrcweir					shift
205cdf0e10cSrcweir					;;
206cdf0e10cSrcweir				--body)
207cdf0e10cSrcweir					TEMPLATE="`basename $0`.mutt.XXXXXXXX"
208cdf0e10cSrcweir					BODY=`mktemp -q -t ${TEMPLATE}`
209cdf0e10cSrcweir					echo "$2" > $BODY
210cdf0e10cSrcweir					shift
211cdf0e10cSrcweir					;;
212cdf0e10cSrcweir				--attach)
213cdf0e10cSrcweir					ATTACH="$2"
214cdf0e10cSrcweir					shift
215cdf0e10cSrcweir					;;
216cdf0e10cSrcweir				*)
217cdf0e10cSrcweir					;;
218cdf0e10cSrcweir			esac
219cdf0e10cSrcweir			shift;
220cdf0e10cSrcweir		done
221*14c7d0b5Smseidel
222cdf0e10cSrcweir		x-terminal-emulator -e ${MAILER} \
223cdf0e10cSrcweir			${FROM:+-e} ${FROM:+"set from=\"${FROM}\""} \
224cdf0e10cSrcweir			${CC:+-c} ${CC:+"${CC}"} \
225cdf0e10cSrcweir			${BCC:+-b} ${BCC:+"${BCC}"} \
226cdf0e10cSrcweir			${SUBJECT:+-s} ${SUBJECT:+"${SUBJECT}"} \
227cdf0e10cSrcweir			${BODY:+-i} ${BODY:+"${BODY}"} \
228cdf0e10cSrcweir			${ATTACH:+-a} ${ATTACH:+"${ATTACH}"} \
229cdf0e10cSrcweir			${TO:+"${TO}"} &
230cdf0e10cSrcweir		rm -f $BODY
231cdf0e10cSrcweir		;;
232*14c7d0b5Smseidel
233cdf0e10cSrcweir	evolution)
234*14c7d0b5Smseidel
235cdf0e10cSrcweir		while [ "$1" != "" ]; do
236cdf0e10cSrcweir			case $1 in
237cdf0e10cSrcweir				--to)
238cdf0e10cSrcweir					if [ "${TO}" != "" ]; then
239cdf0e10cSrcweir						MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
240cdf0e10cSrcweir					else
241cdf0e10cSrcweir						TO="$2"
242cdf0e10cSrcweir					fi
243cdf0e10cSrcweir					shift
244cdf0e10cSrcweir					;;
245cdf0e10cSrcweir				--cc)
246ba2c76b2SAriel Constenla-Haile					MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | "${URI_ENCODE}"`
247cdf0e10cSrcweir					shift
248cdf0e10cSrcweir					;;
249cdf0e10cSrcweir				--bcc)
250ba2c76b2SAriel Constenla-Haile					MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | "${URI_ENCODE}"`
251cdf0e10cSrcweir					shift
252cdf0e10cSrcweir					;;
253cdf0e10cSrcweir				--subject)
254ba2c76b2SAriel Constenla-Haile					MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | "${URI_ENCODE}"`
255cdf0e10cSrcweir					shift
256cdf0e10cSrcweir					;;
257cdf0e10cSrcweir				--body)
258ba2c76b2SAriel Constenla-Haile					MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | "${URI_ENCODE}"`
259cdf0e10cSrcweir					shift
260cdf0e10cSrcweir					;;
261cdf0e10cSrcweir				--attach)
262ba2c76b2SAriel Constenla-Haile					MAILTO="${MAILTO:-}${MAILTO:+&}attach="`echo "file://$2" | "${URI_ENCODE}"`
263cdf0e10cSrcweir					shift
264cdf0e10cSrcweir					;;
265cdf0e10cSrcweir				*)
266cdf0e10cSrcweir					;;
267cdf0e10cSrcweir			esac
268cdf0e10cSrcweir			shift;
269cdf0e10cSrcweir		done
270*14c7d0b5Smseidel
271cdf0e10cSrcweir		MAILTO="mailto:${TO}?${MAILTO}"
272cdf0e10cSrcweir		${MAILER} "${MAILTO}" &
273cdf0e10cSrcweir		;;
274*14c7d0b5Smseidel
275cdf0e10cSrcweir	groupwise)
276*14c7d0b5Smseidel
277cdf0e10cSrcweir		while [ "$1" != "" ]; do
278cdf0e10cSrcweir			case $1 in
279cdf0e10cSrcweir				--to)
280cdf0e10cSrcweir					if [ "${TO}" != "" ]; then
281cdf0e10cSrcweir						MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
282cdf0e10cSrcweir					else
283cdf0e10cSrcweir						TO="$2"
284cdf0e10cSrcweir					fi
285cdf0e10cSrcweir					shift
286cdf0e10cSrcweir					;;
287cdf0e10cSrcweir				--cc)
288ba2c76b2SAriel Constenla-Haile					MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | "${URI_ENCODE}"`
289cdf0e10cSrcweir					shift
290cdf0e10cSrcweir					;;
291cdf0e10cSrcweir				--bcc)
292ba2c76b2SAriel Constenla-Haile					MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | "${URI_ENCODE}"`
293cdf0e10cSrcweir					shift
294cdf0e10cSrcweir					;;
295cdf0e10cSrcweir				--subject)
296ba2c76b2SAriel Constenla-Haile					MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | "${URI_ENCODE}"`
297cdf0e10cSrcweir					shift
298cdf0e10cSrcweir					;;
299cdf0e10cSrcweir				--body)
300ba2c76b2SAriel Constenla-Haile					MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | "${URI_ENCODE}"`
301cdf0e10cSrcweir					shift
302cdf0e10cSrcweir					;;
303cdf0e10cSrcweir				--attach)
304ba2c76b2SAriel Constenla-Haile					MAILTO="${MAILTO:-}${MAILTO:+&}attachment="`echo "file://$2" | "${URI_ENCODE}"`
305cdf0e10cSrcweir					shift
306cdf0e10cSrcweir					;;
307cdf0e10cSrcweir				*)
308cdf0e10cSrcweir					;;
309cdf0e10cSrcweir			esac
310cdf0e10cSrcweir			shift;
311cdf0e10cSrcweir		done
312*14c7d0b5Smseidel
313cdf0e10cSrcweir		MAILTO="mailto:${TO}?${MAILTO}"
314cdf0e10cSrcweir		${MAILER} "${MAILTO}" &
315cdf0e10cSrcweir		;;
316cdf0e10cSrcweir
317cdf0e10cSrcweir	dtmail)
318*14c7d0b5Smseidel
319cdf0e10cSrcweir		while [ "$1" != "" ]; do
320cdf0e10cSrcweir			case $1 in
321cdf0e10cSrcweir				--to)
322cdf0e10cSrcweir					TO=${TO:-}${TO:+,}$2
323cdf0e10cSrcweir					shift
324cdf0e10cSrcweir					;;
325cdf0e10cSrcweir				--attach)
326cdf0e10cSrcweir					ATTACH="$2"
327cdf0e10cSrcweir					shift
328cdf0e10cSrcweir					;;
329cdf0e10cSrcweir				*)
330cdf0e10cSrcweir					;;
331cdf0e10cSrcweir			esac
332cdf0e10cSrcweir			shift;
333cdf0e10cSrcweir		done
334*14c7d0b5Smseidel
335cdf0e10cSrcweir		${MAILER} ${TO:+-T} ${TO:-} ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"}
336cdf0e10cSrcweir		;;
337cdf0e10cSrcweir
338*14c7d0b5Smseidel	sylpheed | claws | claws-mail)
339*14c7d0b5Smseidel
340cdf0e10cSrcweir		while [ "$1" != "" ]; do
341cdf0e10cSrcweir			case $1 in
342cdf0e10cSrcweir				--to)
343cdf0e10cSrcweir					TO=${TO:-}${TO:+,}$2
344cdf0e10cSrcweir					shift
345cdf0e10cSrcweir					;;
346cdf0e10cSrcweir				--attach)
347cdf0e10cSrcweir					ATTACH="${ATTACH:-}${ATTACH:+ }$2"
348cdf0e10cSrcweir					shift
349cdf0e10cSrcweir					;;
350cdf0e10cSrcweir				*)
351cdf0e10cSrcweir					;;
352cdf0e10cSrcweir			esac
353cdf0e10cSrcweir			shift;
354cdf0e10cSrcweir		done
355*14c7d0b5Smseidel
356cdf0e10cSrcweir		 ${MAILER} ${TO:+--compose} "${TO:-}" ${ATTACH:+--attach} "${ATTACH:-}"
357cdf0e10cSrcweir		;;
358cdf0e10cSrcweir
359cdf0e10cSrcweir	Mail | Thunderbird | *.app )
360cdf0e10cSrcweir
361cdf0e10cSrcweir		while [ "$1" != "" ]; do
362cdf0e10cSrcweir			case $1 in
363cdf0e10cSrcweir				--attach)
364cdf0e10cSrcweir					#i95688# fix filenames containing accented chars, whatever alien
365ba2c76b2SAriel Constenla-Haile					ATTACH="${ATTACH:-}${ATTACH:+ }"`echo "file://$2" | "${URI_ENCODE}"`
366cdf0e10cSrcweir					shift
367cdf0e10cSrcweir					;;
368cdf0e10cSrcweir				*)
369cdf0e10cSrcweir					;;
370cdf0e10cSrcweir			esac
371cdf0e10cSrcweir			shift;
372cdf0e10cSrcweir		done
373cdf0e10cSrcweir		/usr/bin/open -a "${MAILER}" ${ATTACH}
374cdf0e10cSrcweir		;;
375cdf0e10cSrcweir
376cdf0e10cSrcweir	"")
377*14c7d0b5Smseidel
378cdf0e10cSrcweir		# DESKTOP_LAUNCH, see http://freedesktop.org/pipermail/xdg/2004-August/004489.html
379cdf0e10cSrcweir		if [ -n "$DESKTOP_LAUNCH" ]; then
380cdf0e10cSrcweir			while [ "$1" != "" ]; do
381cdf0e10cSrcweir				case $1 in
382cdf0e10cSrcweir					--to)
383cdf0e10cSrcweir						if [ "${TO}" != "" ]; then
384cdf0e10cSrcweir							MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
385cdf0e10cSrcweir						else
386cdf0e10cSrcweir							TO="$2"
387cdf0e10cSrcweir						fi
388cdf0e10cSrcweir						shift
389cdf0e10cSrcweir						;;
390cdf0e10cSrcweir					--cc)
391ba2c76b2SAriel Constenla-Haile						MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | "${URI_ENCODE}"`
392cdf0e10cSrcweir						shift
393cdf0e10cSrcweir						;;
394cdf0e10cSrcweir					--bcc)
395ba2c76b2SAriel Constenla-Haile						MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | "${URI_ENCODE}"`
396cdf0e10cSrcweir						shift
397cdf0e10cSrcweir						;;
398cdf0e10cSrcweir					--subject)
399ba2c76b2SAriel Constenla-Haile						MAILTO="${MAILTO:-}${MAILTO:+&}subject="`echo "$2" | "${URI_ENCODE}"`
400cdf0e10cSrcweir						shift
401cdf0e10cSrcweir						;;
402cdf0e10cSrcweir					--body)
403ba2c76b2SAriel Constenla-Haile						MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | "${URI_ENCODE}"`
404cdf0e10cSrcweir						shift
405cdf0e10cSrcweir						;;
406cdf0e10cSrcweir					--attach)
407ba2c76b2SAriel Constenla-Haile						MAILTO="${MAILTO:-}${MAILTO:+&}attachment="`echo "$2" | "${URI_ENCODE}"`
408cdf0e10cSrcweir						shift
409cdf0e10cSrcweir						;;
410cdf0e10cSrcweir					*)
411cdf0e10cSrcweir						;;
412cdf0e10cSrcweir				esac
413cdf0e10cSrcweir				shift;
414cdf0e10cSrcweir			done
415*14c7d0b5Smseidel
416cdf0e10cSrcweir			MAILTO="mailto:${TO}?${MAILTO}"
417cdf0e10cSrcweir			${DESKTOP_LAUNCH} "${MAILTO}" &
418cdf0e10cSrcweir		else
419cdf0e10cSrcweir			echo "Could not determine a mail client to use."
420cdf0e10cSrcweir			exit 2
421cdf0e10cSrcweir		fi
422cdf0e10cSrcweir		;;
423*14c7d0b5Smseidel
424cdf0e10cSrcweir	*)
425cdf0e10cSrcweir		echo "Unsupported mail client: `basename $MAILER | sed 's/-.*^//'`"
426cdf0e10cSrcweir		exit 2
427cdf0e10cSrcweir		;;
428*14c7d0b5Smseidelesac
429*14c7d0b5Smseidel
430cdf0e10cSrcweirexit 0
431