Patch #12493

Fill the Return-Path email header with the correct email address

Added by Jérôme BATAILLE almost 5 years ago. Updated 6 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Email notifications
Target version:-

Description

Value to use : Setting.mail_from

Patch made from Rails 1.2.1, I suppose it will work with more recent versions

add_return_path_header.diff Magnifier (575 Bytes) Jérôme BATAILLE, 2012-12-03 17:16

add_return_path_header.diff Magnifier (575 Bytes) Jérôme BATAILLE, 2012-12-03 17:18

40-actionmailer_base_patch.rb Magnifier (1.9 KB) Jérôme BATAILLE, 2013-07-23 17:59

40-actionmailer_base_patch.rb Magnifier - domain name email address to adapt to your company (1.85 KB) Jérôme BATAILLE, 2013-07-23 18:05

History

#2 Updated by Jérôme BATAILLE almost 5 years ago

Sorry the first patch is wrong

#3 Updated by Jan Niggemann (redmine.org team member) over 4 years ago

RFC2821:
When the delivery SMTP server makes the "final delivery" of a message, it inserts a return-path line at the beginning of the mail data.

http://stackoverflow.com/questions/1235534/what-is-the-behavior-difference-between-return-path-reply-to-and-from:
The Return-Path (sometimes called the Reverse-Path or Envelope-FROM -- all of these terms can be used interchangeably) is the value used during the SMTP session. As you can see, this does not need to be the same value that is actually found in the mail headers. Only the recipient's mail server is supposed to add a Return-Path header to the top of the email. This records the actual Return-Path sender during the SMTP session. If a Return-Path header is already exists in the email, then that header is to be removed, and replaced by the recipient's mail server.

Reading this, I don't think we need to implement this, what do you think?

#4 Updated by Jérôme BATAILLE about 4 years ago

Hi again, I had to add a Return-Path header in emails send by a Redmine instance.
I think that only the sender can determine a correct (non default) Return-Path.
The case is the following :
E-mails are send with the default email address :
But we want that the real user initiating the action receives the bounce emails, because he will be the one knowing how to fix wrong recipients emails (and not the application adminstrators that have other cats to whip :-) ).
We use this and it works perfectly well with exim on the application server and zimbra as the final company mail server.

#5 Updated by Jérôme BATAILLE about 4 years ago

Here is a patch based on ActionMailer (override of actionmailer-2.3.14/lib/action_mailer/base.rb)
to put in config/initializers/

So no need of a Redmine update

#7 Updated by Jérôme BATAILLE over 3 years ago

We now override the Mailer model initialize method

with :

         def initialize_with_return_path(*args)
            initialize_without_return_path(*args)

            # Specific : Return-path changed for the user making the change
            # Only for company members (*@[country_iso_code.]smile[-<country>].[extension])
            if (
              User.current.mail.present? &&
              (
                # A regexp to identify your company users by their email
                # You can use something else
                /@([a-z]+\.)?smile(-[a-zA-Z1-9]+|)?\.[a-z]+$/.match(User.current.mail)
              )
            )
              headers['Return-Path'] = User.current.mail
              # Rails.logger.debug "==>mail Return-Path=#{headers['Return-Path']} (#{User.current.mail})" 
            end
            # END -- Specific
          end

#8 Updated by Jérôme BATAILLE over 3 years ago

  • Status changed from New to Resolved

This patch is specific to each company, so it can't be integrated to the code core.

#9 Updated by Toshi MARUYAMA over 3 years ago

  • Status changed from Resolved to Closed

#10 Updated by Jérôme BATAILLE 7 months ago

Hi, you can indicate in the Resolution that's it Won't be Fixed, if you have the time to, thanks a lot.

#11 Updated by Toshi MARUYAMA 6 months ago

Jérôme BATAILLE wrote:

Hi, you can indicate in the Resolution that's it Won't be Fixed, if you have the time to, thanks a lot.

"Patch" tracker does not have "Resolution" filed.

Also available in: Atom PDF