-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Pro] Site email handling for pro users #3706
[Pro] Site email handling for pro users #3706
Conversation
925dcf8
to
fb7e6f5
Compare
This comment has been minimized.
This comment has been minimized.
@crowbot - I think the only spec failures here are the ones occurring everywhere in pro regarding month arithmetic, so this should be ready for a review when you have a moment. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR is making an unintended change which adds the headers that indicate that the message was autogenerated and that out of office replies should be suppressed to lots of messages that didn't previously have them. A couple of other less significant style/naming comments inline.
app/mailers/contact_mailer.rb
Outdated
headers('Return-Path' => blackhole_email, | ||
'Reply-To' => MailHandler.address_from_name_and_email(name, email)) | ||
reply_to_address = MailHandler.address_from_name_and_email(name, email) | ||
auto_generated_headers('Reply-To' => reply_to_address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to set the 'Auto-Submitted' => 'auto-generated'
and 'X-Auto-Response-Suppress' => 'OOF'
headers here, I don't think the 'Auto-Submitted' => 'auto-generated'
one is appropriate as it shouldn't be used on manually generated messages, only on messages that are automatically created.
app/mailers/contact_mailer.rb
Outdated
# Do not set envelope from address to the from_user, so they can't get | ||
# someone's email addresses from transitory bounce messages. | ||
headers('Return-Path' => blackhole_email, 'Reply-To' => from_user.name_and_email) | ||
auto_generated_headers('Reply-To' => from_user.name_and_email) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I don't think the autogenerated headers for 'Auto-Submitted'
and 'X-Auto-Response-Suppress'
are right for this email
:to => user.name_and_email, | ||
:subject => _("Your batch request \"{{title}}\" has been sent", | ||
:title => info_request_batch.title.html_safe)) | ||
mail_user( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to use the headers that we don't want.
app/mailers/request_mailer.rb
Outdated
# Return path is an address we control so that SPF checks are done on it. | ||
headers('Return-Path' => blackhole_email, | ||
'Reply-To' => user.name_and_email) | ||
auto_generated_headers(:reply_to => user.name_and_email) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue, some of these headers aren't appropriate.
:to => info_request.user.name_and_email, | ||
:subject => _("New response to your FOI request - {{request_title}}", | ||
:request_title => info_request.title.html_safe), | ||
:charset => "UTF-8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we've lost the charset here?
app/mailers/user_mailer.rb
Outdated
mail(:from => contact_from_name_and_email, | ||
:to => user.name_and_email, | ||
:subject => reasons[:email_subject]) | ||
mail_user(user, reasons[:email_subject]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, we don't want the `auto-submitted' and 'auto-reply-suppress' headers here.
end | ||
|
||
def already_registered(user, reasons, url) | ||
@reasons, @name, @url = reasons, user.name, url | ||
headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email) # we don't care about bounces when people are fiddling with their account |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue here
app/mailers/user_mailer.rb
Outdated
end | ||
|
||
def changeemail_confirm(user, new_email, url) | ||
@name, @url, @old_email, @new_email = user.name, url, user.email, new_email | ||
headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email) # we don't care about bounces when people are fiddling with their account | ||
auto_generated_headers('Reply-To' => contact_for_user(user)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want some of these headers, as in previous cases.
app/mailers/user_mailer.rb
Outdated
:to => new_email, | ||
:subject => _("Confirm your new email address on {{site_name}}", :site_name => site_name)) | ||
end | ||
|
||
def changeemail_already_used(old_email, new_email) | ||
@old_email, @new_email = old_email, new_email | ||
headers('Return-Path' => blackhole_email, 'Reply-To' => contact_from_name_and_email) # we don't care about bounces when people are fiddling with their account | ||
user = User.find_by_email(@old_email) | ||
auto_generated_headers('Reply-To' => contact_for_user(user)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same again.
lib/reply_handler.rb
Outdated
@@ -0,0 +1,125 @@ | |||
# -*- encoding : utf-8 -*- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this ought to be a submodule of `mail_handler?
This comment has been minimized.
This comment has been minimized.
@crowbot - sorry, I hadn't really thought through the impact of setting those headers everywhere. I've made some changes to I've also put |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment inline, but other than that, looks great!
app/mailers/contact_mailer.rb
Outdated
mail(:from => contact_from_name_and_email, | ||
|
||
recipient_user = User.find_by_email(recipient_email) | ||
set_reply_to_headers(recipient_user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're adding new reply-to
and return-path
headers here. I don't think it should make any substantial difference, but maybe better to leave it as it is, as it's not the focus of this PR?
So that we can only set the appropriate things. To be re-ordered before changes to individual mailers
To make it more obvious that this file uses a custom contact address
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
75bef5e
to
8bb6946
Compare
This combines mysociety/alaveteli-professional#75 mysociety/alaveteli-professional#138 and
mysociety/alaveteli-professional#140 into a single branch, since they're all related
and need each other to really work correctly.
This PR:
two different addresses, one for replies from pro users and one for
everything else
possible
Closes mysociety/alaveteli-professional#75
Closes mysociety/alaveteli-professional#138
Closes mysociety/alaveteli-professional#140