Gravar-mail: Ion selectivity from local configurations of ligands in solutions and ion channels