Send with Symfony
Send email from Symfony with the usend PHP SDK, or through Symfony Mailer over SMTP.
You need a verified domain and an API key. Use the SDK for API features (templates, batches, scheduling, idempotency), or Symfony Mailer over SMTP so existing MailerInterface code keeps working.
Option 1: the PHP SDK
composer require usend/usendservices:
Usend\Client:
arguments:
$apiKey: '%env(USEND_API_KEY)%'use Usend\Client;
final class Welcome
{
public function __construct(private Client $usend) {}
public function send(string $to): void
{
$this->usend->emails->send([
'from' => 'Acme <[email protected]>',
'to' => [$to],
'subject' => 'Welcome',
'html' => '<p>It works!</p>',
], 'welcome-' . md5($to));
}
}A failure throws Usend\UsendException; rate limits and server errors are retried, and the idempotency key makes a retry safe. See Idempotency. Verify webhooks with Usend\Webhook::verify($request->getContent(), $request->headers->all(), $secret).
Option 2: Symfony Mailer over SMTP
MAILER_DSN=smtps://usend:[email protected]:465Port 465 is implicit TLS (smtps); for STARTTLS use smtp://usend:[email protected]:587. Your API key is the password; URL-encode it if it has special characters ($usend->smtpConfig()['dsn'] does this). See Send with SMTP.
Without the SDK
Symfony's HttpClient works too: POST https://api.usend.et/emails with an Authorization: Bearer header and a JSON body.
Next: Send emails.