I created a function:
`function registerToAcyMaling($email,$name,$password) {
$listClass = acymailing_get('class.list');
$allLists = $listClass->getLists();
$myUser = new stdClass();
$myUser->email = $email;
$myUser->name = $name; //this information is optional
$myUser->confirmed = 1;
$myUser->password = $password;
$myUser->login = $email;
$subscriberClass = acymailing_get('class.subscriber');
$subid = $subscriberClass->save($myUser); //this function will return you the ID of the user inserted in the AcyMailing table`
The error occurs when the last line tries to save user that already have email in database. For example when I already have user with email "example@example.com" and try to save another user with the same email.