3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 URI_ENCODE
=`dirname "$0"`/uri-encode
22 sd_platform
=`uname -s`
24 # linux file utility needs -L option to resolve symlinks
25 if [ "$sd_platform" = "Linux" ] ; then
29 # do not confuse the system mail clients with OOo and Java libraries
39 # tries to locate the executable specified
40 # as first parameter in the user's path.
42 if [ ! -z "$1" ]; then
43 for i
in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
44 if [ -x "$i/$1" -a ! -d "$i/$1" ]; then
52 # checks for the original mozilla start script(s)
53 # and restrict the "-remote" semantics to those.
55 # find mozilla script in PATH if necessary
56 if [ "`basename $1`" = "$1" ]; then
62 if file $FOPTS "$moz" |
grep "script" > /dev
/null
&& grep "[NM]PL" "$moz" > /dev
/null
; then
63 "$moz" -remote 'ping()' 2>/dev
/null
>/dev
/null
67 "$1" -remote "xfeDoCommand(composeMessage,$2)" &
74 if [ "$1" = "--mailclient" ]; then
80 # autodetect mail client from executable name
81 case `basename "$MAILER" | sed 's/-.*$//'` in
83 iceape | mozilla | netscape | seamonkey | icedove | thunderbird
)
85 while [ "$1" != "" ]; do
96 BCC
=${BCC:-}${BCC:+,}$2
108 ATTACH
=${ATTACH:-}${ATTACH:+,}`echo "file://$2" | "${URI_ENCODE}"`
117 if [ "$TO" != "" ]; then
118 COMMAND=${COMMAND:-}${COMMAND:+,}to=\'${TO}\'
120 if [ "$CC" != "" ]; then
121 COMMAND=${COMMAND:-}${COMMAND:+,}cc=\'${CC}\'
123 if [ "$BCC" != "" ]; then
124 COMMAND=${COMMAND:-}${COMMAND:+,}bcc=\'${BCC}\'
126 if [ "$SUBJECT" != "" ]; then
127 COMMAND=${COMMAND:-}${COMMAND:+,}subject=\'${SUBJECT}\'
129 if [ "$BODY" != "" ]; then
130 COMMAND=${COMMAND:-}${COMMAND:+,}body=\'${BODY}\'
132 if [ "$ATTACH" != "" ]; then
133 COMMAND=${COMMAND:-}${COMMAND:+,}attachment=\'${ATTACH}\'
136 run_mozilla "$MAILER" "$COMMAND"
141 while [ "$1" != "" ]; do
144 TO="${TO:-}${TO:+,}$2"
148 CC="${CC:-}${CC:+,}$2"
152 BCC="${BCC:-}${BCC:+,}$2"
168 ATTACH="${ATTACH:-}${ATTACH:+ }--attach "`echo "file://$2" | "${URI_ENCODE}"`
177 ${MAILER} --composer \
178 ${CC:+--cc} ${CC:+"${CC}"} \
179 ${BCC:+--bcc} ${BCC:+"${BCC}"} \
180 ${SUBJECT:+--subject} ${SUBJECT:+"${SUBJECT}"} \
181 ${BODY:+--body} ${BODY:+"${BODY}"} \
182 ${FROM:+--header} ${FROM:+"From: ${FROM}"} \
183 ${ATTACH:+${ATTACH}} \
189 while [ "$1" != "" ]; do
196 TO="${TO:-}${TO:+,}$2"
200 CC="${CC:-}${CC:+,}$2"
204 BCC="${BCC:-}${BCC:+,}$2"
212 TEMPLATE="`basename $0`.mutt.XXXXXXXX
"
213 BODY=`mktemp -q -t ${TEMPLATE}`
227 x-terminal-emulator -e ${MAILER} \
228 ${FROM:+-e} ${FROM:+"set from=\"${FROM}\""} \
229 ${CC:+-c} ${CC:+"${CC}"} \
230 ${BCC:+-b} ${BCC:+"${BCC}"} \
231 ${SUBJECT:+-s} ${SUBJECT:+"${SUBJECT}"} \
232 ${BODY:+-i} ${BODY:+"${BODY}"} \
233 ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"} \
238 evolution | gnome | xdg) # NB. shortened from the dash on
240 while [ "$1" != "" ]; do
243 if [ "${TO}" != "" ]; then
244 MAILTO="${MAILTO:-}${MAILTO:+&}to
=$2"
251 MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | "${URI_ENCODE}"`
255 MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | "${URI_ENCODE}"`
259 MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | "${URI_ENCODE}"`
263 MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | "${URI_ENCODE}"`
267 MAILTO="${MAILTO:-}${MAILTO:+&}attach="`echo "file://$2" | "${URI_ENCODE}"`
276 MAILTO="mailto
:${TO}?
${MAILTO}"
277 ${MAILER} "${MAILTO}" &
282 while [ "$1" != "" ]; do
285 if [ "${TO}" != "" ]; then
286 MAILTO="${MAILTO:-}${MAILTO:+&}to
=$2"
293 MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | "${URI_ENCODE}"`
297 MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | "${URI_ENCODE}"`
301 MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | "${URI_ENCODE}"`
305 MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | "${URI_ENCODE}"`
309 MAILTO="${MAILTO:-}${MAILTO:+&}attachment="`echo "file://$2" | "${URI_ENCODE}"`
318 MAILTO="mailto
:${TO}?
${MAILTO}"
319 ${MAILER} "${MAILTO}" &
324 while [ "$1" != "" ]; do
340 ${MAILER} ${TO:+-T} ${TO:-} ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"}
345 while [ "$1" != "" ]; do
352 ATTACH="${ATTACH:-}${ATTACH:+ }$2"
361 ${MAILER} ${TO:+--compose} "${TO:-}" ${ATTACH:+--attach} "${ATTACH:-}"
364 Mail | Thunderbird |
*.app
)
366 while [ "$1" != "" ]; do
369 #i95688# fix filenames containing accented chars, whatever alien
370 ATTACH
="${ATTACH:-}${ATTACH:+ }"`echo "file://$2" | "${URI_ENCODE}"`
378 /usr/bin/open -a "${MAILER}" ${ATTACH}
383 # LO is configured to use something we do not recognize, or is not configured.
384 # Try to be smart, and send the mail anyway, if we have the
385 # possibility to do so.
387 if [ -n "$DESKTOP_LAUNCH" ]; then
388 # http://lists.freedesktop.org/pipermail/xdg/2004-August/002873.html
389 MAILER=${DESKTOP_LAUNCH}
390 elif [ -n "$KDE_FULL_SESSION" -a -x /usr/bin/kde-open ] ; then
391 MAILER=/usr/bin/kde-open
392 elif [ -n "$GNOME_DESKTOP_SESSION_ID" -a -x /usr/bin/gnome-open ] ; then
393 MAILER=/usr/bin/gnome-open
394 elif [ -x /usr/bin/xdg-open ] ; then
395 MAILER=/usr/bin/xdg-open
397 echo "Unsupported mail client: `basename $MAILER |
sed 's/-.*^//'`"
401 while [ "$1" != "" ]; do
404 if [ "${TO}" != "" ]; then
405 MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
412 MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | "${URI_ENCODE}"`
416 MAILTO
="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | "${URI_ENCODE}"`
420 MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | "${URI_ENCODE}"`
424 MAILTO
="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | "${URI_ENCODE}"`
428 MAILTO="${MAILTO:-}${MAILTO:+&}attachment="`echo "file://$2" | "${URI_ENCODE}"`
437 MAILTO
="mailto:${TO}?${MAILTO}"
438 ${MAILER} "${MAILTO}" &