php – SwiftMailer ReturnPath

Question:

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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
    $body .= '<html xmlns="http://www.w3.org/1999/xhtml">';
    $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>';



    Yii::$app->mailer->useTransport('system')->compose()
        ->setFrom(['example@some.com' => 'example.com'])
        ->setReturnPath('bounced@some.com')
        ->addHeader('Reply-To', 'bounced@some.com')
        ->setTo('example2@some.com')
        ->setSubject('TEST MESSAGE')
        ->setHtmlBody($body)
        ->send();

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

UDP.
Mailjet is used to mailjet .

Answer:

Have you tried specifying setSender() instead of setReturnPath ?

These people also had similar problems:

https://github.com/swiftmailer/swiftmailer/issues/384

https://stackoverflow.com/questions/26762802/phpmailer-bounced-mails-not-getting-bounced-right/26765956#26765956

Scroll to Top