8000 [Symfony/Mailer] mailer.envelope.recipients configuration does not work with sendmail · Issue #41149 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Symfony/Mailer] mailer.envelope.recipients configuration does not work with sendmail #41149
Closed
@arnolem

Description

@arnolem

Symfony version(s) affected: 5.2.7 / 6.0.1

Description
Symfony/Mailer : The recipients feature ("Always Send to the same Address") does not work with sendmail

How to reproduce

<?php
ini_set('display_errors', true);

use Symfony\Component\Mailer\Envelope;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport\SendmailTransport;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;

require_once __DIR__ . './vendor/autoload.php';

// Configure your email
$sender    = new Address('from@mail.com');
$to        = new Address('to+fail@mail.com');
$recipient = new Address('to+success@mail.com');

// Use sendmail Transport
$mailer = new Mailer(new SendmailTransport());

// Force recipients to always override recipients
// https://symfony.com/doc/current/mailer.html#always-send-to-the-same-address
$enveloppe = new Envelope($sender, [$recipient]);

$email = new Email();
$email->text('content');
$email->from($sender);
$email->to($to);

$mailer->send($email, $enveloppe);

The email is sent to "to" instead of "recipient"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0