Graylog2 / graylog2-server

Free and open log management
https://www.graylog.org
Other
7.33k stars 1.06k forks source link

Allow setting name in from address for email notifications #15364

Open JTP3XP opened 1 year ago

JTP3XP commented 1 year ago

There appear to be 2 ways to set the "from" email address for email notifications:

  1. Set the config parameter transport_email_from_email (directly or via env variable GRAYLOG_TRANSPORT_EMAIL_FROM_EMAIL)
  2. Set the optional sender value in a notification's settings

Expected Behavior

When the email is received it should appear to come from the specified address

Current Behavior

The email always comes from the email address used for authentication

Steps to Reproduce (for bugs)

  1. Set GRAYLOG_TRANSPORT_EMAIL_FROM_EMAIL env variable in a container running Graylog
  2. Send a notification from the node
  3. Populate the sender field in the notification settings via the UI
  4. Send another notification

Both notifications will be sent without changing the sender address from the authentication address.

Context

It would be valuable to be able to control the from address because we reuse mail accounts for multiple services and changing the from address allows us to set up filters in our mail accounts to route messages from different sources appropriately.

On a related note, it can be a nice bit of polish to be able to utilize the name in addition to the email address, which should be possible by just using another overload of the setFrom method already in use.

Your Environment

moesterheld commented 1 year ago

@JTP3XP Thanks for reporting this. I am having a hard time reproducing this. Could it be that your SMTP server will automatically rewrite the from address to the one used for authentication? Often, SMTP servers will raise an error if the address in the from field does not match the one of the user authenticating against it. Maybe yours will try to rewrite it? What mail system are you using?

JTP3XP commented 1 year ago

@moesterheld You are right - we are using Gmail and they require you to do some configuration on your account before you can change the sender email address in outgoing emails. Thanks for the nudge in the right direction.

I still believe enabling the use of the name parameter in the other setFrom overload (perhaps with a new config parameter) would be a valuable enhancement. It would allow folks to change the name easily, especially when the smtp server does not allow the mismatch between the sender address and authentication address. This could also make it trivial to specify many different sender names in different alerts if the option was added to the alerts UI (today I would have to set up and validate every different alias on the Gmail side - and Gmail has limits on how many aliases you can use). It's also nice for the from label to not be restricted to valid email addresses, so you can have the emails coming from "Graylog" rather than "graylog@domain.com".

For example, the attached screenshot shows my options today in graylog - I can have it use the "mail@..." authentication address or an alias for the account that shows up as "graylog@...". But I cannot have a nice formatted name like "GitHub" or "Graylog Alerts". It's even worse in Outlook where the lack of name makes the preview pane show the whole email address instead of just the username part.

Snag_2d66006c

Is this something you all might add?

moesterheld commented 1 year ago

@JTP3XP Glad to be of help. I'll change this issue to a feature request and will put it in our backlog.