From 77d4873ee653549eb8fb8761253f9feb1eea1c11 Mon Sep 17 00:00:00 2001 From: David Steele Date: Tue, 24 Apr 2012 00:18:02 -0400 Subject: fdo#32621: Fall back to using the GNOME mailto URI handler if no valid mail program found --- shell/source/unix/misc/senddoc.sh | 49 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'shell/source') diff --git a/shell/source/unix/misc/senddoc.sh b/shell/source/unix/misc/senddoc.sh index 9d63ae3df63b..692930ec2eec 100755 --- a/shell/source/unix/misc/senddoc.sh +++ b/shell/source/unix/misc/senddoc.sh @@ -400,8 +400,53 @@ case `basename "$MAILER" | sed 's/-.*$//'` in ;; *) - echo "Unsupported mail client: `basename $MAILER | sed 's/-.*^//'`" - exit 2 + if [ -x /usr/bin/gnome-open ] ; then + MAILER = /usr/bin/gnome-open + elif [ -x /usr/bin/xdg-open ] ; then + MAILER = /usr/bin/xdg-open + else + echo "Unsupported mail client: `basename $MAILER | sed 's/-.*^//'`" + exit 2 + fi + + while [ "$1" != "" ]; do + case $1 in + --to) + if [ "${TO}" != "" ]; then + MAILTO="${MAILTO:-}${MAILTO:+&}to=$2" + else + TO="$2" + fi + shift + ;; + --cc) + MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | ${URI_ENCODE}` + shift + ;; + --bcc) + MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | ${URI_ENCODE}` + shift + ;; + --subject) + MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | ${URI_ENCODE}` + shift + ;; + --body) + MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | ${URI_ENCODE}` + shift + ;; + --attach) + MAILTO="${MAILTO:-}${MAILTO:+&}attach="`echo "file://$2" | ${URI_ENCODE}` + shift + ;; + *) + ;; + esac + shift; + done + + MAILTO="mailto:${TO}?${MAILTO}" + ${MAILER} "${MAILTO}" & ;; esac -- cgit