V8-archive: Add 'from' setting to /mail endpoint

Created on 20 Mar 2019  路  5Comments  路  Source: directus/v8-archive

Feature Request

Steps to Reproduce

  1. Configure mail in api.php or any project api.php file:
'default' => [
  'transport' => 'sendmail',
  'from' => '[email protected]'
]
  1. Mail some recipient ([email protected]) using the /mail endpoint and provide access via token:
POST /_/mail?access_token=adminUserSecretToken

{
  "to": [
    "[email protected]"
  ],
  "subject": "New Password",
  "body": "Hello <b>{{name}}</b>, this is your new password: {{password}}.",
  "type": "html",
  "data": {
    "name": "John Doe",
    "password": "secret"
  }
}
  1. As [email protected] check your email and the sender address.

Expected Behavior

The sender address is: [email protected]

Actual Behavior

The sender address is the email address of the (admin) user corresponding to the used access_token: [email protected]

Other Context & Screenshots

Nope.

Technical Details

  • Device: Desktop, Chrome latest
  • OS: MacOs latest
  • Web Server: Apache 2.4
  • PHP Version: 7.2
  • Database: 5.6
  • Install Method: Cloned master branch
enhancement

Most helpful comment

Makes sense, thanks Binal!

Let's shift this ticket to a feature request for now and we can look into adding it later. For now the priority is bug fixes and stability.

All 5 comments

Thank you for pointing this out @stefanvangastel. We'll be looking at this issue soon 馃檪

Hello @stefanvangastel , this is working as expected. What you're trying to achieve can be added as an enhancement though. Let me explain,

The api.config file has mail settings which are being used when the system sends an email for activities like:

  1. New registration
  2. Forgot passwords etc.

The /mail endpoint is open for all the users. It identifies the user from access token & sets the email of the user as the sender. Now there may be some cases where you might need to tweak this behaviour. To do that we can add an extra parameter use_default_email which will use the email address from the configuration.

This may create a situation where other user can also pass this parameter and represent them as a system email. So we can add check that if the token is of an admin then only use_default_email will come to a picture!

Let me know your thoughts @benhaynes @rijkvanzanten

@bjgajjar That explains a lot. Thanks. I understand this point of view and the suggested feature would be very helpful for my (and I expect other) use-case(s).

Makes sense, thanks Binal!

Let's shift this ticket to a feature request for now and we can look into adding it later. For now the priority is bug fixes and stability.

Fixed in #911

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jwkellyiii picture jwkellyiii  路  3Comments

cdwmhcc picture cdwmhcc  路  3Comments

rijkvanzanten picture rijkvanzanten  路  3Comments

Varulv1997 picture Varulv1997  路  3Comments

andgar2010 picture andgar2010  路  3Comments