Allow From, Reply-To addresses to be overridden in settings table#272
Allow From, Reply-To addresses to be overridden in settings table#272
Conversation
This is needed to prevent emails from being sent with incorrect addresses in the header when setting a different mailer username.
|
Hi @Holmes98!
I'm curious -- why do these need to be set separately? I would expect to
have a single email address for both SMTP auth and "From". Otherwise it's
effectively spoofing the sender, which I think would be better to avoid if
possible.
|
|
I don't know why, but maybe there are cases where the SMTP username isn't the same as the email address. I guess we could still set the fields from |
|
Actually, it's probably just because Action Mailer has other delivery methods than SMTP (e.g. sendmail). |
|
Actually, how did you change the website to send emails using train@nzoi.org.nz? I assumed it was by changing system/mailer/username (and generating a password etc.), but then I don't see how there would still be references to nztrain@gmail.com.
|
|
Yeah, I just changed the For emails from Devise, the from/reply_to parameters seem to be set from the nztrain/config/initializers/devise.rb Line 13 in 8e102ad Emails from the admin panel currently use this (which I removed in this PR): nztrain/app/mailers/admin_mailer.rb Line 2 in 8e102ad |
|
Right, thanks for digging that up. I consider that a bug -- we shouldn't
hard-code that email address. How about I write a separate PR to change it
to use system/mailer/username, and then this PR would only be necessary for
setting a custom display name?
|
|
Sure. |
|
I'm mostly done (branch "pr/remove-hard-coded-nztrain-email" of my fork, commits). One question is how the settings should work. I would strongly prefer that in the simplest case (where the admin doesn't want to set a pretty display name), the email would only have to be configured in one setting. Here are the options I like: A. "system/mailer/email" for auth and default "From:", setting "system/mailer/from" to override "From:" (may contain a display name). B. "system/mailer/email" for auth and "From:", "system/mailer/display_name" (optional) added to "From:". (For both options, a migration could rename "system/mailer/username" to "system/mailer/email".) Also, is Reply-To useful, or was it just a workaround? |
|
That looks reasonable. I'm fine with either of those options, or even just hardcoding the display name to "NZOI Training", since there are already hardcoded references to that elsewhere on the site.
Nice find, I guess that's why the specs were breaking for me earlier. Reply-To was mostly a workaround. I could see it maybe being useful for redirecting responses to an mailbox that's actually monitored, but it's probably not important. |
|
I implemented the hard-coded display name and opened #273. |
I've changed the website to send emails using train@nzoi.org.nz, but this currently causes emails to be sent with incorrect headers:
This would also allow setting the sender's display name, e.g.
"NZOI Training" <train@nzoi.org.nz>; currently Gmail just shows the sender as "train" or "nztrain".