Fri, 10 Jul 2015

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:

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

# output file location
ADDR_FILE=~/.owncloud_contacts.vcf
TIMEOUT=30
# config file location
CONFIG=~/.owncloud_contacts.cfg
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
fi

# owncloud link to export contacts
LINK=https://${HOST}/owncloud/remote.php/carddav/addressbooks/${USER}/contacts?export

# 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.

posted at: 01:33 | path: /debian | permanent link to this entry


2019-Jun
2019-May
2018-Dec
2018-Jan
2017-Aug
2017-Jun
2017-May
2016-Nov
2015-Dec
2015-Nov
2015-Oct
2015-Jul
2015-Jun
2014-Dec
2012-Oct
2012-Sep
2012-Jun
2012-Feb
2012-Jan
2011-Dec
2011-Sep
2011-Aug
2011-May
2011-Feb
2010-Jun
2010-Apr
2010-Jan
2009-Sep
2009-Jul
2009-May
2009-Jan
2008-Oct
2008-Sep
2008-Jun
2008-May
2008-Jan
2007-Nov
2007-Oct
2007-Aug
2007-Jun
2007-May
2007-Mar
2007-Feb
2007-Jan
2006-Nov
2006-Oct
2006-Sep
2006-Aug
2006-Jun
2006-Apr
2006-Jan
2005-Dec
2005-Nov
2005-Oct
2005-Sep
2005-Aug
2005-Jul
2005-Jun
2005-May
2005-Apr
2005-Mar
2005-Feb
2005-Jan
2004-Dec
2004-Nov
2004-Oct
2004-Sep
2004-Aug
2004-Jul
2004-Jun
2004-May

Powered by PyBlosxom | RSS 2.0