I'm stuck in a weird problem.
Everytime I try to create an account and add an address to that account programmatically I get an error called
A customer with the same email already exists in an associated website
This is my code for adding shipping and billing address to customer.
$customer->save();
$customer->sendNewAccountEmail();
//$customerId = $customer->getId();
//Address info
$customerAddress = $this->customerFactory->create()->setWebsiteId($websiteId)->loadByEmail($customer_email);
$customerId = $customerAddress->getId();
$address = $this->addressDataFactory->create();
$address->setFirstname($parameters["first-name"])
->setLastname($parameters["last-name"])
->setCountryId("US")
//->setRegionId("1")
//->setRegion("")
->setCity('n/a')
->setPostcode($parameters["zip"])
->setCompany('n/a')
->setCustomerId($customerId)
->setStreet(['n/a'])
->setTelephone($parameters["phone"])
>setIsDefaultBilling(1)
->setIsDefaultShipping(1);
$this->addressRepository->save($address);
Of course I'm adding differnt emails everytime I run this controller, but for some reason it keeps telling me that the email is already associated with another customer.
Please help