coolify/bootstrap/helpers/email.php
Andras Bacsai 7d699818e8 fix: harden Vultr create, Gmail identity, and provider retries
Wrap Vultr server creation in DB transactions and delete the remote
instance when local persistence fails (API and Livewire). Scope
plus/dot email normalization to gmail.com/googlemail.com only.
Use throw:false on DigitalOcean/Vultr HTTP retries, and normalize
service log line counts via normalizeLogLines.
2026-07-16 13:42:53 +02:00

23 lines
546 B
PHP

<?php
use Illuminate\Support\Str;
function normalize_email_identity(?string $email): ?string
{
if (blank($email) || ! str_contains($email, '@')) {
return null;
}
[$localPart, $domain] = explode('@', Str::lower(trim($email)), 2);
if (in_array($domain, ['gmail.com', 'googlemail.com'], true)) {
$localPart = Str::before($localPart, '+');
$localPart = str_replace('.', '', $localPart);
}
if (blank($localPart) || blank($domain)) {
return null;
}
return $localPart.'@'.$domain;
}