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
32 # tries to locate the executable specified
33 # as first parameter in the user's path.
35 if [ ! -z "$1" ]; then
36 for i
in $
(echo "$PATH" |
sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'); do
37 if [ -x "$i/$1" -a ! -d "$i/$1" ]; then
45 # checks for the original mozilla start script(s)
46 # and restrict the "-remote" semantics to those.
48 # find mozilla script in PATH if necessary
49 if [ "$(basename "$1")" = "$1" ]; then
55 if file $FOPTS "$moz" |
grep "script" > /dev
/null
&& grep "[NM]PL" "$moz" > /dev
/null
; then
56 "$moz" -remote 'ping()' 2>/dev
/null
>/dev
/null
60 "$1" -remote "xfeDoCommand(composeMessage,$2)" &
67 if [ "$1" = "--mailclient" ]; then
73 # autodetect mail client from executable name
74 case $
(basename "$MAILER" |
sed 's/-.*$//') in
76 iceape | mozilla | netscape | seamonkey | icedove | thunderbird | betterbird
)
78 while [ "$1" != "" ]; do
89 BCC
=${BCC:-}${BCC:+,}$2
101 ATTACH
=${ATTACH:-}${ATTACH:+,}$(echo "file://$2" | "${URI_ENCODE}")
110 if [ "$TO" != "" ]; then
111 COMMAND=${COMMAND:-}${COMMAND:+,}to=\'${TO}\'
113 if [ "$CC" != "" ]; then
114 COMMAND=${COMMAND:-}${COMMAND:+,}cc=\'${CC}\'
116 if [ "$BCC" != "" ]; then
117 COMMAND=${COMMAND:-}${COMMAND:+,}bcc=\'${BCC}\'
119 if [ "$SUBJECT" != "" ]; then
120 COMMAND=${COMMAND:-}${COMMAND:+,}subject=\'${SUBJECT}\'
122 if [ "$BODY" != "" ]; then
123 COMMAND=${COMMAND:-}${COMMAND:+,}body=\'${BODY}\'
125 if [ "$ATTACH" != "" ]; then
126 COMMAND=${COMMAND:-}${COMMAND:+,}attachment=\'${ATTACH}\'
129 run_mozilla "$MAILER" "$COMMAND"
134 while [ "$1" != "" ]; do
137 TO="${TO:-}${TO:+,}$2"
141 CC="${CC:-}${CC:+,}$2"
145 BCC="${BCC:-}${BCC:+,}$2"
161 ATTACH="${ATTACH:-}${ATTACH:+ }--attach "$(echo "file://$2" | "${URI_ENCODE}")
170 ${MAILER} --composer \
171 ${CC:+--cc} ${CC:+"${CC}"} \
172 ${BCC:+--bcc} ${BCC:+"${BCC}"} \
173 ${SUBJECT:+--subject} ${SUBJECT:+"${SUBJECT}"} \
174 ${BODY:+--body} ${BODY:+"${BODY}"} \
175 ${FROM:+--header} ${FROM:+"From: ${FROM}"} \
176 ${ATTACH:+${ATTACH}} \
182 while [ "$1" != "" ]; do
189 TO="${TO:-}${TO:+,}$2"
193 CC="${CC:-}${CC:+,}$2"
197 BCC="${BCC:-}${BCC:+,}$2"
205 TEMPLATE="$
(basename "$0").mutt.XXXXXXXX
"
206 BODY=$(mktemp -q -t "${TEMPLATE}")
220 x-terminal-emulator -e ${MAILER} \
221 ${FROM:+-e} ${FROM:+"set from=\"${FROM}\""} \
222 ${CC:+-c} ${CC:+"${CC}"} \
223 ${BCC:+-b} ${BCC:+"${BCC}"} \
224 ${SUBJECT:+-s} ${SUBJECT:+"${SUBJECT}"} \
225 ${BODY:+-i} ${BODY:+"${BODY}"} \
226 ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"} \
231 evolution | gnome | xdg) # NB. shortened from the dash on
233 while [ "$1" != "" ]; do
236 if [ "${TO}" != "" ]; then
237 MAILTO="${MAILTO:-}${MAILTO:+&}to
=$2"
244 MAILTO="${MAILTO:-}${MAILTO:+&}cc="$(echo "$2" | "${URI_ENCODE}")
248 MAILTO="${MAILTO:-}${MAILTO:+&}bcc="$(echo "$2" | "${URI_ENCODE}")
252 MAILTO="${MAILTO:-}${MAILTO:+&}subject"=$(echo "$2" | "${URI_ENCODE}")
256 MAILTO="${MAILTO:-}${MAILTO:+&}body="$(echo "$2" | "${URI_ENCODE}")
260 MAILTO="${MAILTO:-}${MAILTO:+&}attach="$(echo "file://$2" | "${URI_ENCODE}")
269 MAILTO="mailto
:${TO}?
${MAILTO}"
270 ${MAILER} "${MAILTO}" &
275 while [ "$1" != "" ]; do
278 if [ "${TO}" != "" ]; then
279 MAILTO="${MAILTO:-}${MAILTO:+&}to
=$2"
286 MAILTO="${MAILTO:-}${MAILTO:+&}cc="$(echo "$2" | "${URI_ENCODE}")
290 MAILTO="${MAILTO:-}${MAILTO:+&}bcc="$(echo "$2" | "${URI_ENCODE}")
294 MAILTO="${MAILTO:-}${MAILTO:+&}subject"=$(echo "$2" | "${URI_ENCODE}")
298 MAILTO="${MAILTO:-}${MAILTO:+&}body="$(echo "$2" | "${URI_ENCODE}")
302 MAILTO="${MAILTO:-}${MAILTO:+&}attachment="$(echo "file://$2" | "${URI_ENCODE}")
311 MAILTO="mailto
:${TO}?
${MAILTO}"
312 ${MAILER} "${MAILTO}" &
317 while [ "$1" != "" ]; do
333 ${MAILER} ${TO:+-T} ${TO:-} ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"}
338 while [ "$1" != "" ]; do
345 ATTACH=${ATTACH:-}${ATTACH:+,}$(echo "file://$2" | "${URI_ENCODE}")
354 ${MAILER} ${TO:+--compose} ${TO:-} ${ATTACH:+--attach} ${ATTACH:-}
357 Mail | Thunderbird | Betterbird |
*.app
)
359 while [ "$1" != "" ]; do
362 #i95688# fix filenames containing accented chars, whatever alien
363 ATTACH
="${ATTACH:-}${ATTACH:+ }"$(echo "file://$2" | "${URI_ENCODE}")
371 /usr
/bin
/open
-a "${MAILER}" ${ATTACH}
376 # LO is configured to use something we do not recognize, or is not configured.
377 # Try to be smart, and send the mail anyway, if we have the
378 # possibility to do so.
380 if [ -x /usr
/bin
/xdg-email
] ; then
381 MAILER
=/usr
/bin
/xdg-email
382 elif [ -n "$DESKTOP_LAUNCH" ]; then
383 # http://lists.freedesktop.org/pipermail/xdg/2004-August/002873.html
384 MAILER
=${DESKTOP_LAUNCH}
385 elif [ -n "$KDE_FULL_SESSION" -a -x /usr
/bin
/kde-open
] ; then
386 MAILER
=/usr
/bin
/kde-open
387 elif [ -x /usr
/bin
/xdg-open
] ; then
388 MAILER
=/usr
/bin
/xdg-open
389 elif command -v xdg-open
>/dev
/null
2>&1 ; then
390 MAILER
=$
(command -v xdg-open
)
392 echo "Unsupported mail client: $(basename $MAILER | sed 's/-.*^//')"
396 while [ "$1" != "" ]; do
399 if [ "${TO}" != "" ]; then
400 MAILTO
="${MAILTO:-}${MAILTO:+&}to=$2"
407 MAILTO
="${MAILTO:-}${MAILTO:+&}cc="$(echo "$2" | "${URI_ENCODE}")
411 MAILTO
="${MAILTO:-}${MAILTO:+&}bcc="$(echo "$2" | "${URI_ENCODE}")
415 MAILTO
="${MAILTO:-}${MAILTO:+&}subject"=$(echo "$2" | "${URI_ENCODE}")
419 MAILTO
="${MAILTO:-}${MAILTO:+&}body="$(echo "$2" | "${URI_ENCODE}")
423 if [ "$MAILER" = "/usr/bin/xdg-email" ]; then
424 MAILTO
="${MAILTO:-}${MAILTO:+&}attach="$(echo "file://$2" | "${URI_ENCODE}")
426 MAILTO
="${MAILTO:-}${MAILTO:+&}attachment="$(echo "file://$2" | "${URI_ENCODE}")
436 MAILTO
="mailto:${TO}?${MAILTO}"
437 ${MAILER} "${MAILTO}" &