Mastitis at calving is primarily caused by environmental bacteria contracted during the dry period or when calving down in wet, muddy conditions.