FIX: Use reply-to address for incoming emails if present (PR #13896)

When the Reply-To header is present for incoming emails we want to use it instead of the from address. This is usually the case when forwarding an email via a mailing list into Discourse.

GitHub

Do you need to try here? nil.to_s should be fine

If we make previous change, then you will not need &. as we will end with empty string in worse case

And the same for from_address too. If this line is called, it is only because from_address contains an @, so it is definitely not empty.

Just copied what we already had for :from underneath :slight_smile: Will clean both paths up.

          from_display_name = address_field.display_name&.to_s

Adding to the other comments: This line will result in an error if from_address is nil.

If this line is executed, it is only because from_address contains an @, so it is definitely not empty.

This is actually not the case; this test is used to catch a from address without an @, so I need to leave the check in

https://github.com/discourse/discourse/blob/fa984731abfa8713300b5a4ef19ad0d71fd46909/spec/components/email/receiver_spec.rb#L425-L427

@gschlager , @udan11, @lis2 can you please take another look at this one?