I am not sure if the code or the documentation is the problem here, but let's start with the documentation. For reference, the manual says this today: Email: the email address field is not required, but it should be filled for every library in your system - Note: Be sure to enter a library email address to make sure that notices are sent to and from the right address - Note: If no email address is entered here, the address in the KohaAdminEmailAddress system preference will be used to send notices from this library Reply-To: you can enter a different ‘Reply-To’ email address. This is the email address that all replies will go to. - Note: If no email address is entered here, the address in the ReplytoDefault system preference will be used to receive replies to this library Return-Path: you can enter a different ‘Return-Path’ email address. This is the email address that all bounced messages will go to. - Note: If no email address is entered here, the address in the ReturnpathDefault system preference will be used to receive bounced messages from this library. https://koha-community.org/manual/latest/en/html/administration.html#adding-a-library Mu scenario is as follows: We host Koha for a number of libraries that want to send messages to their patrons by email. For some libraries we can't send email through their SMTP for different reasons. So we set up a noreply address with a domain that we control, so that we can use that as the sender of the emails, and we can do our best to set up SPF, DKIM etc for it, so it won't be seen as spam by services such as Gmail. Based on the description above, I set it up like this: Email = noreply Reply-To = real library email Return-Path = real library email But it turns out that when postfix was processing the email, and passing it on to our SMTP server, it was seeing the "real library email" from the Return-Path setting as the "from" address, not the "noreply" address that we wanted it to see. So the question is: - Is the code wrong in using the Return-Path address as the "from" address? - Or is the documentation wrong in saying that the Return-Path is just for bounced messages? See also: Bug 28729 - Return-path header not set in emails
Hi Magnuse, (In reply to Magnus Enger from comment #0) > I am not sure if the code or the documentation is the problem here, but > let's start with the documentation. > > For reference, the manual says this today: > > Email: the email address field is not required, but it should be filled for > every library in your system > - Note: Be sure to enter a library email address to make sure that notices > are sent to and from the right address > - Note: If no email address is entered here, the address in the > KohaAdminEmailAddress system preference will be used to send notices from > this library > > Reply-To: you can enter a different ‘Reply-To’ email address. This is the > email address that all replies will go to. > - Note: If no email address is entered here, the address in the > ReplytoDefault system preference will be used to receive replies to this > library Hm, I had remembered it differently, but Email.pm indicates it might be correct: $addresses->{reply_to} ||= C4::Context->preference('ReplytoDefault') if C4::Context->preference('ReplytoDefault'); > Return-Path: you can enter a different ‘Return-Path’ email address. This is > the email address that all bounced messages will go to. > - Note: If no email address is entered here, the address in the > ReturnpathDefault system preference will be used to receive bounced messages > from this library. Same here: $addresses->{sender} = $params->{sender}; $addresses->{sender} ||= C4::Context->preference('ReturnpathDefault') if C4::Context->preference('ReturnpathDefault'); > https://koha-community.org/manual/latest/en/html/administration.html#adding- > a-library > > Mu scenario is as follows: We host Koha for a number of libraries that want > to send messages to their patrons by email. For some libraries we can't send > email through their SMTP for different reasons. So we set up a noreply > address with a domain that we control, so that we can use that as the sender > of the emails, and we can do our best to set up SPF, DKIM etc for it, so it > won't be seen as spam by services such as Gmail. > > Based on the description above, I set it up like this: > > Email = noreply > Reply-To = real library email > Return-Path = real library email We also use this setup, but I believe yours won't work yet. You also need to se the Return-path to an email address from the domain of your mail server to avoid being marked as spam. See: https://wiki.koha-community.org/wiki/MRenvoize/Email We use library specific emails for this and then forward the emails to the library's email automatically in our mail server somehow (I know it works, but haven't set it up). > But it turns out that when postfix was processing the email, and passing it > on to our SMTP server, it was seeing the "real library email" from the > Return-Path setting as the "from" address, not the "noreply" address that we > wanted it to see. Hm, that's surprising. Did you set all the fields on library and system preference level? It can be a bit messy to test and sometimes also depends a bit on the notices and what is sent to Email.pm. > So the question is: > - Is the code wrong in using the Return-Path address as the "from" address? > - Or is the documentation wrong in saying that the Return-Path is just for > bounced messages? The documentation appears correct to me. Have you tried tracking this in the code to see where it comes from? Maybe some weird fallbacks for an empty branch email or so?