php – SwiftMailer ReturnPath


Hello, there is a problem with letters that are returned if they were not delivered for some reason.

They need to be redirected to another email.
But the return-path header doesn't work.

I set my return-path , but, after sending, the letter comes not to the mailbox specified, but to the one from which it was sent, and my installed email is overwritten in the letter.

An example of my code:

    $body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">';
    $body .= '<html xmlns="">';
    $body .= '<head>';
    $body .= '<meta http-equiv="Content-Type" content="text/html; charset="' . Yii::$app->charset . '" />';
    $body .= '<title></title>';
    $body .= '</head>';
    $body .= '<body>';
    $body .= 'Test Message';
    $body .= '</body>';
    $body .= '</html>';

        ->setFrom(['' => ''])
        ->addHeader('Reply-To', '')
        ->setSubject('TEST MESSAGE')

I use swiftmailer to send mail.

I have been googling for a long time, setting any other headings has not led to a positive result.

Do you have any options?

Headers who come back:

Return-path: <>
Delivery-date: Thu, 13 Oct 2016 17:42:28 +0300
Received: from ([])
    by with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256)
    (Exim 4.84)
    (envelope-from <>)
    id 1buhDH-0002DI-S0
    for; Thu, 13 Oct 2016 17:42:27 +0300
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;; s=dkim;
    h=Content-Transfer-Encoding:Content-Type:MIME-Version:To:From:Subject:Date:Message-ID; bh=TJEj83H/pPguf4pMS+4FcdmBzKkRiY+DeLg2oWD2/iQ=;
Received: from [] (helo=[])
    by with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256)
    (Exim 4.84_2)
    (envelope-from <>)
    id 1buhDG-0001i4-Su
    for; Thu, 13 Oct 2016 10:42:27 -0400
Message-ID: <34cb7242e992226ad1d1f74b821c325f@swift.generated>
Date: Thu, 13 Oct 2016 10:42:25 -0400
From: "" <>
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Mailjet is used to mailjet .


Have you tried specifying setSender() instead of setReturnPath ?

These people also had similar problems:

Scroll to Top