Export owncloud contacts for use in claws-mail

I wanted to setup claws-mail to be able to load contacts from owncloud recently. There is no direct way to do this as far as I can tell, but I did find some people exporting the contacts list to a vcf file, and then pointing claws-mail to use contacts from this file. This ends up working pretty well, and automating it with a script to update makes it a good enough solution.

I had a lot of trouble finding the proper url to wget the addresses from in owncloud 8.2 which is what I'm using. What ended up working, and wasn't really documented anywhere I was looking was https://${HOST}/owncloud/remote.php/carddav/addressbooks/${USER}/contacts?export - The key bit being the ?export at the end of the url.

I'm using the following bash script to do the export, which was adopted from an older blog post doing the same thing:

# Script to read Addresses from ownCloud an put it in a file that can read by
# Claws-Mail

# output file location
# config file location
source ${CONFIG}

if [ -z "$USER" ] || [ -z "$HOST" ] || [ -z "$PASS" ]; then
   echo "ERROR: config file is not setup correctly"
   echo "create ${CONFIG} with the contents:"
   echo "HOST="
   echo "USER="
   echo "PASS="
   exit 1

# owncloud link to export contacts

# Get the data!
OPTIONS="--output-document=$ADDR_FILE --auth-no-challenge --timeout=$TIMEOUT --http-user=$USER"
wget ${OPTIONS} --http-password="${PASS}" ${LINK}

Running the above script will output a ~/.owncloud_contacts.vcf file which can be loaded into claws mail as a new VCard address book. Running the script again will overwrite the file with updated data, and claws mail sees the new addresses.

Previous: Triple monitor setup with two video cards using nouveau Next: Using qmail-autoresponder with qmailadmin