symfony5postmarksymfony-mailer

Problems integrating Postmark with Symfony Mailer


I am currently struggeling trying to use Postmark with the Symfony5 Mailer Bundle. Although the documentation seems to be clear, i am unable to send any emails.

My first point of confusion is the suggested DSN format for Postmark:

postmark+smtp://ID@default

It seems unclear what ID should be used, as Postmark, for SMTP, provides Username and Password, as well as an Acces Key and Secret Key (SMTP Token). An ID, as requested, is not provided.

Does anyone know what configurations should be used here?

Thank you in advance!


Solution

  • I just got it working so far with To, CC and BCC.

    I'm not using Symfony5 but implemented the SmyonfyMailer in our application.

    Packages i had to install:

    composer require symfony/mailer
    composer require symfony/postmark-mailer
    composer require symfony/http-client
    

    If you instantiate the symfony mailer class you can pass the transport object like this (i use the API, not SMTP).

    
    use Symfony\Component\Mailer\Mailer;
    use Symfony\Component\Mailer\Transport;
    
    $dsn = 'postmark+api://' . <postmark-api-key> . '@default';
    
    $transport = Transport::fromDsn($dsn);
    
    $mailer = new Mailer($transport);
    
    $email = (new Email())
                ->from('hello@example.com')
                ->to('you@example.com')
                //->cc('cc@example.com')
                //->bcc('bcc@example.com')
                //->replyTo('fabien@example.com')
                //->priority(Email::PRIORITY_HIGH)
                ->subject('Time for Symfony Mailer!')
                ->text('Sending emails is fun again!')
                ->html('<p>See Twig integration for better HTML integration!</p>');
    
    $mailer->send($email);