View Single Post
  #1   (View Single Post)  
Old 8th October 2008
BSDKaffee's Avatar
BSDKaffee BSDKaffee is offline
Real Name: Jason Hale
Coffee Addict
 
Join Date: May 2008
Location: Wintersville, Ohio
Posts: 212
Default Sending PRs through KMail

Sending Problem Reports Through KMail

If you use KMail, you may wish to send your problem reports from send-pr through KMail instead of another mail program. The advantage of this is you already have KMail setup for your outgoing mail, so there is no need to setup another mail program. Plus all of your PRs will be stored in KMail like your other outgoing mail.

This guide has been developed for usage with FreeBSD's send-pr program, but will most likely work with any program that outputs an email message. I developed this guide mostly because it took me a while to figure out how to do this in KDE4 because it uses DBUS (which I'm not real familiar with). I have been doing this in KDE3 for a while, however.

Use the send-pr program as normal and follow the below instructions.

Intermediary Script
The following shell scripts will act as an interface between send-pr and KMail. I have provided a script for KDE 3.x and one for KDE 4.x. Be sure to use the correct one as KDE 3.x uses DCOP for communication and KDE 4.x uses DBUS. Both scripts are attached for convenience; you may save them anywhere you wish. I will use ~/src/scripts/ as an example.

KDE 3.x Script:
Code:
#!/bin/sh

# sendprbykmail-kde3.sh
# Send PRs from send-pr through KMail for KDE 3.x

# Location/name of temporary file
# DEFAULT: /tmp/kmail-pr-<PID>
TMPDIR="/tmp"
TMPFILE="kmail-pr-$$"

# Name of KMail mail folder used for outgoing mail
# DEFAULT: outbox
OUTBOX="outbox"

# Create a temorary file containing the output of send-pr
cat - > ${TMPDIR}/${TMPFILE}

# Check if KMail is running, if so place the PR in the outbox
if dcop kmail ; then
	dcop kmail KMailIface dcopAddMessage ${OUTBOX} ${TMPDIR}/${TMPFILE} N
	rm ${TMPDIR}/${TMPFILE}
	exit 0
else
# If KMail is not running, PR is saved
	echo "** PR not sent. Copy stored in ${TMPDIR}/${TMPFILE}"
	exit 1
fi
KDE 4.x script:
Code:
#!/bin/sh

# sendprbykmail-kde4.sh
# Send PRs from send-pr through KMail for KDE 4.x

# Location/name of temporary file
# DEFAULT: /tmp/kmail-pr-<PID>
TMPDIR="/tmp"
TMPFILE="kmail-pr-$$"

# Name of KMail mail folder used for outgoing mail
# DEFAULT: outbox
OUTBOX="outbox"

# Create a temorary file containing the output of send-pr
cat - > ${TMPDIR}/${TMPFILE}

# Check if KMail is running, if so place the PR in the outbox
if qdbus org.kde.kmail ; then
	qdbus org.kde.kmail /KMail org.kde.kmail.kmail.dbusAddMessage ${OUTBOX} ${TMPDIR}/${TMPFILE}
	rm ${TMPDIR}/${TMPFILE}
	exit 0
else
# If KMail is not running, PR is saved
	echo "** PR not sent. Copy stored in ${TMPDIR}/${TMPFILE}"
	exit 1
fi
Environment
send-pr uses the MAIL_AGENT environment variable to determine which program to use to send the PR. The default is to use sendmail. You will want to set this to the path of the script.

In sh-like shells:
$ export MAIL_AGENT=~/src/scripts/sendprbykmail-kde3.sh

In csh-like shells:
$ setenv MAIL_AGENT ~/src/scripts/sendprbykmail-kde3.sh

You may wish to add this environment variable to your ~./profile, ~./cshrc, ~./bashrc, etc. for future use.

Closing
Now you should have a PR sitting in your KMail outbox. You may have to send the queued messages in the outbox through KMail depending on how you have your outbox configured.
Attached Files
File Type: sh sendprbykmail-kde3.sh (663 Bytes, 80 views)
File Type: sh sendprbykmail-kde4.sh (695 Bytes, 75 views)
Reply With Quote