}
// Connect emails with uids
foreach ($domain_mails as $email => $user) {
- $uids[$email] = $domain_uids[$user];
+ // Some 'domain' emails might be invalid.
+ if (array_key_exists($user, $domain_uids)) {
+ $uids[$email] = $domain_uids[$user];
+ }
}
// Look up user ids for addresses in our alias domain
}
// Connect emails with uids
foreach ($alias_mails as $email => $user) {
- $uids[$email] = $alias_uids[$user];
+ if (array_key_exists($user, $alias_uids)) {
+ $uids[$email] = $alias_uids[$user];
+ }
}
// Look up user ids for other addresses in the email redirection list
if (count($other_mails)) {
+ $lowerupper = array();
+ foreach ($other_mails as $mail) {
+ $lowerupper[strtolower($mail)] = $mail;
+ }
$res = XDB::query("SELECT email, uid
FROM emails
WHERE email IN {?}", $other_mails);
foreach ($res->fetchAllRow() as $row) {
list ($email, $uid) = $row;
- $uids[$email] = $uid;
+ $uids[$lowerupper[strtolower($email)]] = $uid;
}
}
if (!isvalid_email_redirection($email_stripped)) {
return ERROR_LOOP_EMAIL;
}
- XDB::execute('REPLACE INTO emails (uid,email,flags) VALUES({?},{?},"active")', $this->user->id(), $email);
+ // If the email was already present for this user, we reset it to the default values, we thus use REPLACE INTO.
+ XDB::execute('REPLACE INTO emails (uid, email, flags)
+ VALUES ({?}, {?}, \'active\')',
+ $this->user->id(), $email);
if ($logger = S::v('log', null)) { // may be absent --> step4.php
S::logger()->log('email_add', $email . ($this->user->id() != S::v('uid') ? " (admin on {$this->user->login()})" : ""));
}