Skip to content

[Mailer] AbstractTransport#send() implicitly requires Message instead of RawMessage #33256

Closed
@freiondrej

Description

@freiondrej

Symfony version(s) affected: 4.3.3

Description

Method Symfony\Component\Mailer\Transport\AbstractTransport::send, implementation of Symfony\Component\Mailer\MailerInterface::send(RawMessage $message, SmtpEnvelope $envelope = null) accepts Symfony\Component\Mime\RawMessage, but by default (when $envelope is null) creates Symfony\Component\Mailer\DelayedSmtpEnvelope, which accepts Symfony\Component\Mime\Message. So when I use a smtp transport, I cannot call Symfony\Component\Mailer\MailerInterface::send() with a RawMessage even though the type seems to allow it.

How to reproduce

/**
 * @var MailerInterface
 */
private $mailer;

method() {
    $this->mailer->send(new RawMessage('content'));   // Argument 1 passed to Symfony\Component\Mailer\DelayedSmtpEnvelope::__construct() must be an instance of Symfony\Component\Mime\Message, instance of Symfony\Component\Mime\RawMessage given, called in /var/php/prod/vendor/symfony/mailer/Transport/AbstractTransport.php on line 66
}

Possible Solution

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions