Improved from email address format for notifications.

This commit is contained in:
Dmitry Khomutov 2017-06-21 21:03:57 +07:00
parent ae48f24406
commit 46441106d1
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
3 changed files with 13 additions and 8 deletions

View file

@ -25,7 +25,7 @@ php-censor:
per_page: 10
url: 'http://php-censor.local'
email_settings:
from_address: 'no-reply@php-censor.local'
from_address: 'PHP Censor <no-reply@php-censor.local>'
smtp_address: null
smtp_port: null
smtp_username: null

View file

@ -254,7 +254,7 @@ class InstallCommand extends Command
'url' => $url,
'queue' => $queueConfig,
'email_settings' => [
'from_address' => 'no-reply@php-censor.local',
'from_address' => 'PHP Censor <no-reply@php-censor.local>',
'smtp_address' => null,
'smtp_port' => null,
'smtp_username' => null,

View file

@ -95,13 +95,18 @@ class Email
*/
protected function getFrom()
{
$email = $this->config->get('php-censor.email_settings.from_address', self::DEFAULT_FROM);
if (empty($email)) {
$email = self::DEFAULT_FROM;
$from = $this->config->get(
'php-censor.email_settings.from_address',
self::DEFAULT_FROM
);
if (strpos($from, '<') === false) {
return (string)$from;
}
return $email;
preg_match('#^(.*?)<(.*)>$#ui', $from, $fromParts);
return [$fromParts[2] => $fromParts[1]];
}
/**