Skip to content
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

API Allow array style email addresses #10658

Merged

Conversation

emteknetnz
Copy link
Member

@emteknetnz emteknetnz commented Jan 25, 2023

Comment on lines -206 to +207
$defaultFrom = array_keys($adminEmail)[0];
$email = array_keys($adminEmail)[0];
$defaultFrom = [$email => $adminEmail[$email]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate here that array_keys($adminEmail)[0] is in fact a string (or even go so far as to validate it's a valid RFC email address?

I know the second part of that goes beyond the original purpose of this PR so I'm okay if we say we want to do that but make a card to handle it later - but the former part of that seems like it falls in line with this PR's purpose if we want to do it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation happens within symfony so we don't need to do this here, nor should really should we since we're leveraging symfony to do the heavy lifting

e.g. the following config

SilverStripe\Control\Email\Email:
  admin_email:
    aa: 'Admin-email'

and the following script

$email = new Email();
$email->to('[email protected]')->subject('test')->setBody('abc')->send();

Will result in
[Emergency] Uncaught Symfony\Component\Mime\Exception\RfcComplianceException: Email "aa" does not comply with addr-spec of RFC 2822.

Copy link
Member

@GuySartorelli GuySartorelli Jan 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about

SilverStripe\Control\Email\Email:
  admin_email:
    - '[email protected]'

nvm of course that will have the same complaint, Email "0" does not comply etc

@GuySartorelli GuySartorelli merged commit 8d6fa44 into silverstripe:5 Jan 26, 2023
@GuySartorelli GuySartorelli deleted the pulls/5/array-email branch January 26, 2023 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants