I've seen this happen and I narrowed it down to the fact that the email is not sent when associating the customer to the Admin
website.
When doing this, the website_id
for the customer is 0
and this code is executed in the controller:
if ($customer->getWebsiteId() && (isset($data['account']['sendemail']) || $sendPassToEmail)) {
$storeId = $customer->getSendemailStoreId();
if ($isNewCustomer) {
$customer->sendNewAccountEmail('registered', '', $storeId);
} elseif ((!$customer->getConfirmation())) {
// Confirm not confirmed customer
$customer->sendNewAccountEmail('confirmed', '', $storeId);
}
}
$customer->getWebsiteId()
is 0
so the if
statement is skipped.
but when you edit the same customer again, the next piece of code is executed (right below the one I mentioned) and the e-mail is sent.
if (!empty($data['account']['new_password'])) {
$newPassword = $data['account']['new_password'];
if ($newPassword == 'auto') {
$newPassword = $customer->generatePassword();
}
$customer->changePassword($newPassword);
$customer->sendPasswordReminderEmail();
}