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 # checks for the original mozilla start script(s)
33 # and restrict the "-remote" semantics to those.
35 # find mozilla script in PATH if necessary
36 if [ "$(basename "$1")" = "$1" ]; then
37 moz
=$
(command -v "$1")
42 if file $FOPTS "$moz" |
grep "script" > /dev
/null
&& grep "[NM]PL" "$moz" > /dev
/null
; then
43 "$moz" -remote 'ping()' 2>/dev
/null
>/dev
/null
47 "$1" -remote "xfeDoCommand(composeMessage,$2)" &
54 if [ "$1" = "--mailclient" ]; then
60 # autodetect mail client from executable name
61 case $
(basename "$MAILER" |
sed 's/-.*$//') in
63 iceape | mozilla | netscape | seamonkey | icedove | thunderbird | betterbird
)
65 while [ "$1" != "" ]; do
76 BCC
=${BCC:-}${BCC:+,}$2
88 ATTACH
=${ATTACH:-}${ATTACH:+,}$(echo "file://$2" | "${URI_ENCODE}")
97 if [ "$TO" != "" ]; then
98 COMMAND=${COMMAND:-}${COMMAND:+,}to=\'${TO}\'
100 if [ "$CC" != "" ]; then
101 COMMAND=${COMMAND:-}${COMMAND:+,}cc=\'${CC}\'
103 if [ "$BCC" != "" ]; then
104 COMMAND=${COMMAND:-}${COMMAND:+,}bcc=\'${BCC}\'
106 if [ "$SUBJECT" != "" ]; then
107 COMMAND=${COMMAND:-}${COMMAND:+,}subject=\'${SUBJECT}\'
109 if [ "$BODY" != "" ]; then
110 COMMAND=${COMMAND:-}${COMMAND:+,}body=\'${BODY}\'
112 if [ "$ATTACH" != "" ]; then
113 COMMAND=${COMMAND:-}${COMMAND:+,}attachment=\'${ATTACH}\'
116 run_mozilla "$MAILER" "$COMMAND"
121 while [ "$1" != "" ]; do
124 TO="${TO:-}${TO:+,}$2"
128 CC="${CC:-}${CC:+,}$2"
132 BCC="${BCC:-}${BCC:+,}$2"
148 ATTACH="${ATTACH:-}${ATTACH:+ }--attach "$(echo "file://$2" | "${URI_ENCODE}")
157 ${MAILER} --composer \
158 ${CC:+--cc} ${CC:+"${CC}"} \
159 ${BCC:+--bcc} ${BCC:+"${BCC}"} \
160 ${SUBJECT:+--subject} ${SUBJECT:+"${SUBJECT}"} \
161 ${BODY:+--body} ${BODY:+"${BODY}"} \
162 ${FROM:+--header} ${FROM:+"From: ${FROM}"} \
163 ${ATTACH:+${ATTACH}} \
169 while [ "$1" != "" ]; do
176 TO="${TO:-}${TO:+,}$2"
180 CC="${CC:-}${CC:+,}$2"
184 BCC="${BCC:-}${BCC:+,}$2"
192 TEMPLATE="$
(basename "$0").mutt.XXXXXXXX
"
193 BODY=$(mktemp -q -t "${TEMPLATE}")
207 x-terminal-emulator -e ${MAILER} \
208 ${FROM:+-e} ${FROM:+"set from=\"${FROM}\""} \
209 ${CC:+-c} ${CC:+"${CC}"} \
210 ${BCC:+-b} ${BCC:+"${BCC}"} \
211 ${SUBJECT:+-s} ${SUBJECT:+"${SUBJECT}"} \
212 ${BODY:+-i} ${BODY:+"${BODY}"} \
213 ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"} \
218 evolution | gnome | xdg) # NB. shortened from the dash on
220 while [ "$1" != "" ]; do
223 if [ "${TO}" != "" ]; then
224 MAILTO="${MAILTO:-}${MAILTO:+&}to
=$2"
231 MAILTO="${MAILTO:-}${MAILTO:+&}cc="$(echo "$2" | "${URI_ENCODE}")
235 MAILTO="${MAILTO:-}${MAILTO:+&}bcc="$(echo "$2" | "${URI_ENCODE}")
239 MAILTO="${MAILTO:-}${MAILTO:+&}subject"=$(echo "$2" | "${URI_ENCODE}")
243 MAILTO="${MAILTO:-}${MAILTO:+&}body="$(echo "$2" | "${URI_ENCODE}")
247 MAILTO="${MAILTO:-}${MAILTO:+&}attach="$(echo "file://$2" | "${URI_ENCODE}")
256 MAILTO="mailto
:${TO}?
${MAILTO}"
257 ${MAILER} "${MAILTO}" &
262 while [ "$1" != "" ]; do
265 if [ "${TO}" != "" ]; then
266 MAILTO="${MAILTO:-}${MAILTO:+&}to
=$2"
273 MAILTO="${MAILTO:-}${MAILTO:+&}cc="$(echo "$2" | "${URI_ENCODE}")
277 MAILTO="${MAILTO:-}${MAILTO:+&}bcc="$(echo "$2" | "${URI_ENCODE}")
281 MAILTO="${MAILTO:-}${MAILTO:+&}subject"=$(echo "$2" | "${URI_ENCODE}")
285 MAILTO="${MAILTO:-}${MAILTO:+&}body="$(echo "$2" | "${URI_ENCODE}")
289 MAILTO="${MAILTO:-}${MAILTO:+&}attachment="$(echo "file://$2" | "${URI_ENCODE}")
298 MAILTO="mailto
:${TO}?
${MAILTO}"
299 ${MAILER} "${MAILTO}" &
304 while [ "$1" != "" ]; do
320 ${MAILER} ${TO:+-T} ${TO:-} ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"}
325 while [ "$1" != "" ]; do
332 ATTACH=${ATTACH:-}${ATTACH:+,}$(echo "file://$2" | "${URI_ENCODE}")
341 ${MAILER} ${TO:+--compose} ${TO:-} ${ATTACH:+--attach} ${ATTACH:-}
344 Mail | Thunderbird | Betterbird |
*.app
)
346 while [ "$1" != "" ]; do
349 #i95688# fix filenames containing accented chars, whatever alien
350 ATTACH
="${ATTACH:-}${ATTACH:+ }"$(echo "file://$2" | "${URI_ENCODE}")
358 /usr
/bin
/open
-a "${MAILER}" ${ATTACH}
363 # LO is configured to use something we do not recognize, or is not configured.
364 # Try to be smart, and send the mail anyway, if we have the
365 # possibility to do so.
367 if [ -x /usr
/bin
/xdg-email
] ; then
368 MAILER
=/usr
/bin
/xdg-email
369 elif [ -n "$DESKTOP_LAUNCH" ]; then
370 # http://lists.freedesktop.org/pipermail/xdg/2004-August/002873.html
371 MAILER
=${DESKTOP_LAUNCH}
372 elif [ -n "$KDE_FULL_SESSION" -a -x /usr
/bin
/kde-open
] ; then
373 MAILER
=/usr
/bin
/kde-open
374 elif [ -x /usr
/bin
/xdg-open
] ; then
375 MAILER
=/usr
/bin
/xdg-open
376 elif command -v xdg-open
>/dev
/null
2>&1 ; then
377 MAILER
=$
(command -v xdg-open
)
379 echo "Unsupported mail client: $(basename $MAILER | sed 's/-.*^//')"
383 while [ "$1" != "" ]; do
386 if [ "${TO}" != "" ]; then
387 MAILTO
="${MAILTO:-}${MAILTO:+&}to=$2"
394 MAILTO
="${MAILTO:-}${MAILTO:+&}cc="$(echo "$2" | "${URI_ENCODE}")
398 MAILTO
="${MAILTO:-}${MAILTO:+&}bcc="$(echo "$2" | "${URI_ENCODE}")
402 MAILTO
="${MAILTO:-}${MAILTO:+&}subject"=$(echo "$2" | "${URI_ENCODE}")
406 MAILTO
="${MAILTO:-}${MAILTO:+&}body="$(echo "$2" | "${URI_ENCODE}")
410 if [ "$MAILER" = "/usr/bin/xdg-email" ]; then
411 MAILTO
="${MAILTO:-}${MAILTO:+&}attach="$(echo "file://$2" | "${URI_ENCODE}")
413 MAILTO
="${MAILTO:-}${MAILTO:+&}attachment="$(echo "file://$2" | "${URI_ENCODE}")
423 MAILTO
="mailto:${TO}?${MAILTO}"
424 ${MAILER} "${MAILTO}" &