# Sending FreeBSD problem reports through KMail



## BSDKaffee (Nov 17, 2008)

Sending FreeBSD Problem Reports Through KMail

If you use KMail, you may wish to send your problem reports from send-pr(1) 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.

Use send-pr(1) as usual and follow these instructions:

Intermediary Script
The following shell scripts will act as an interface between send-pr(1) 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.  You may save them anywhere you wish.  

KDE 3.x Script:

```
#!/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:

```
#!/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(1) uses the MAIL_AGENT environment variable to determine which program to use to send the PR.  The default is to use sendmail(8).  You will want to set this to the path of the script.

In sh-like shells:

```
$ export MAIL_AGENT=/path/to/sendprbykmail-kde3.sh
```

In csh-like shells:

```
$ setenv MAIL_AGENT /path/to/sendprbykmail-kde3.sh
```

You may also wish to add this environment variable to your [font="Courier New"]~./profile[/font], [font="Courier New"]~./cshrc[/font], [font="Courier New"]~./bashrc[/font], 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.


----------

