The steps I followed to sync my remote contacts with the claws-mail mail client:
Step 1: Configure vdirsyncer:
Create a new directory:
mkdir -p ~/.contacts
Then create a vdirsyncer configuration file “config” in the default vdirsyncer dir that will probably be this one:
This file must look like this:
status_path = "~/.vdirsyncer/status/"
type = "singlefile"
path = "~/.contacts/%s.vcf"
type = "carddav"
url = "https://yourdomain-here"
username = "your-username"
password = "your-password"
a = "local"
b = "online"
collections = ["from a", "from b"]
conflict_resolution = "b wins"
After that you can run:
vdirsyncer discover contacts
Step 2: Add your contacts to claws-mail:
Tools->AddressBook and select: Book->New vCard
Type a name for your vCard entry and select the downloaded *.vcf file that should be in your .contacts directory after the vdirsyncer sync.
If you have many vcf files in your directory and you don’t know which ones are valid vCard entries you can press Check File and validate there are no error messages first. Press ok and you will see your remote contacts appear in the Address book. Something like this:
Step 3: Create a cron job to sync the contacts automatically:
In case you don’t want to manually run vdirsyncer sync every now and then you can automate it by creating a cronjob. (Note that sync will also update your calendars if you followed the optional steps, so better use “sync contacts” if you only want to sync the contacts)
I wanted to sync everything once a week early in the morning so my cronjob looks like:
0 5 * * 1 /usr/local/bin/vdirsyncer sync > /dev/null
And that’s it.
Note: As I discovered later, if the contacts are frequently updated on the server and UIDs that belonged to deleted contacts are reused for new contacts, you might see some error messages that sync is not possible and you need to use
--repair-unsafe-uid or some other parameters. The easiest way to fix this problem, is by purging your
.config/vdirsyncer/status directory before retrying. Good luck!