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:
I’ve hidden some “sensitive” info although the screenshot was from a list of Igalians, that is public in our site anyway. :p
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!
4 thoughts on “Claws-mail + vdirsyncer (sync contacts)”
I must be doing something wrong but I can’t figure it out. The contact syncing works great but the calendar syncing throws the following error:
$ vdirsyncer discover my_calendar
error: Pair my_calendar does not exist. Please check your configuration file and make sure you’ve typed the pair name correctly
The backend I’m using is Davical and I’ve used your configuration substituting “your_calendar” with “my_calendar”. Any ideas?
Other people also complained that following these steps didn’t work for them, I am going to double check it and update my post. I most probably forgot to write something. Apologies!
you speak about CalDAV syncing at the head of your post. But you describe a WebCal subscription later on:
“Now you must see a new entry in the accounts section called “vCalendar” where you can add your calendars if you right click vCalendar and select: Subscribe to WebCal”
WebCal isnt CalDav — is there any trick I didnt see?
greets from germany,
Good point, my steps don’t seem to work. I am going to remove the calendar part completely and make a new post as soon as I re-do and fix the steps 🙂 Sorry!