<?php
declare(strict_types=1);
function addSubscriber(PDO $pdo,string $email): void {
    $email=mb_strtolower(trim($email));
    if (!filter_var($email,FILTER_VALIDATE_EMAIL)) throw new InvalidArgumentException('Invalid email.');
    $token=bin2hex(random_bytes(32)); $hash=hash('sha256',$token);
    $s=$pdo->prepare('INSERT INTO newsletter_subscribers(email,verification_token_hash,subscribed_at) VALUES(:email,:hash,NOW())');
    $s->execute(['email'=>$email,'hash'=>$hash]);
    // Email the raw token in a verification link; store only its hash.
}
