Slice the tomatoes and onions, and put into a pan with the other ingredients. Stir well and simmer for 2 hours until thick and soft, stirring occasionally. Sieve and return purée to pan. Bring to the boil and boil for 5 minutes. Pour into hot bottles and seal. Sterilize for 30 minutes in a water bath.