Generic framework features, code-only — the tables come from the schema snapshot:
- controllers/account.php — email signup (verified) + Google OAuth (server-side auth-code
flow, async-popup friendly); native password_hash sessions on sp_users; sp_oauth_accounts +
sp_user_tokens; PublicController origin+throttle guards; {ok,data,error} envelope.
- Helpers/Mailer.php — transactional email: Brevo HTTP API (Guzzle) -> SMTP fallback
(PHPMailer) -> logs; config in sp_settings (encrypted).
- cli/rebuild.php — queue a static rebuild (sp_settings rebuild_pending flag) after DB edits.
- cli/resources.php — read a curated source registry (mde_resources) per agent_type.
- db/seed_google_oauth.php, db/seed_email.php — env-seeded encrypted secrets into sp_settings.
- templates/emails/verify.html — verification email template.
- composer.json — declare guzzlehttp/guzzle ^7.10 (account.php + Mailer use GuzzleHttp\Client).
Depends on the schema-snapshot branch (sp_users / sp_oauth_accounts / sp_user_tokens /
sp_settings / mde_resources) plus `composer require guzzlehttp/guzzle`. No data.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FMQeUnUrAeexcZ7P2Hxa6G
38 lines
1.3 KiB
PHP
38 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Seed transactional-email config into sp_settings (encrypted api key).
|
|
*
|
|
* Brevo (https://app.brevo.com → SMTP & API → API keys). Verify your sender domain/
|
|
* address in Brevo first, or delivery will be rejected.
|
|
*
|
|
* Run (from api/):
|
|
* BREVO_API_KEY='xkeysib-...' \
|
|
* EMAIL_FROM='noreply@medellin.co' EMAIL_FROM_NAME='Medellín' \
|
|
* php db/seed_email.php
|
|
*/
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
require __DIR__ . '/../config.php';
|
|
|
|
$apiKey = getenv('BREVO_API_KEY');
|
|
$fromEmail = getenv('EMAIL_FROM') ?: ('noreply@' . (parse_url(URL, PHP_URL_HOST) ?: 'localhost'));
|
|
$fromName = getenv('EMAIL_FROM_NAME') ?: (defined('PROJECT_NAME') ? PROJECT_NAME : 'Website');
|
|
|
|
if ($apiKey === false || $apiKey === '') {
|
|
fwrite(STDERR, "Set BREVO_API_KEY in the environment.\n");
|
|
exit(1);
|
|
}
|
|
|
|
$meta = [
|
|
'provider' => 'brevo',
|
|
'api_key' => \Functions::Encrypt($apiKey),
|
|
'from_email' => $fromEmail,
|
|
'from_name' => $fromName,
|
|
];
|
|
|
|
\Db::execute("DELETE FROM sp_settings WHERE keyval = ?", ['email']);
|
|
\Db::execute(
|
|
"INSERT INTO sp_settings (keyval, `group`, metval, status, encrypted, createdate) VALUES ('email', 'email', ?, 1, 1, ?)",
|
|
[json_encode($meta), date('Y-m-d H:i:s')]
|
|
);
|
|
|
|
echo "saved email (provider=brevo, from={$fromName} <{$fromEmail}>, encrypted=1)\n";
|