Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
smtp
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
smtp
Merge requests
!8
Issue
#3252427
: Provide token support for email addresses used by SMTP config
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#3252427
: Provide token support for email addresses used by SMTP config
issue/smtp-3252427:3252427-provide-token-support
into
8.x-1.x
Overview
0
Commits
1
Pipelines
0
Changes
1
Open
Jürgen Haas
requested to merge
issue/smtp-3252427:3252427-provide-token-support
into
8.x-1.x
3 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
8.x-1.x
8.x-1.x (HEAD)
and
latest version
latest version
9d533d80
1 commit,
3 years ago
1 file
+
63
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
smtp.tokens.inc
0 → 100644
+
63
−
0
Options
<?php
/**
* @file
* Builds placeholder replacement tokens for smtp data.
*
* This file handles tokens for the smtp tokens.
*/
/**
* Implements hook_token_info().
*/
function
smtp_token_info
():
array
{
$types
[
'smtp'
]
=
[
'name'
=>
t
(
"SMTP data"
),
'description'
=>
t
(
"Tokens for smtp settings."
),
];
$smtp
[
'from'
]
=
[
'name'
=>
t
(
"E-mail from address"
),
'description'
=>
t
(
"The e-mail address that all e-mails will be from."
),
];
$smtp
[
'fromname'
]
=
[
'name'
=>
t
(
"E-mail from name"
),
'description'
=>
t
(
"The name that all e-mails will be from."
),
];
$smtp
[
'username'
]
=
[
'name'
=>
t
(
"Username"
),
'description'
=>
t
(
"SMTP Username."
),
];
return
[
'types'
=>
$types
,
'tokens'
=>
[
'smtp'
=>
$smtp
,
],
];
}
/**
* Implements hook_tokens().
*/
function
smtp_tokens
(
$type
,
$tokens
):
array
{
$replacements
=
[];
if
(
$type
===
'smtp'
)
{
$config
=
\Drupal
::
config
(
'smtp.settings'
);
foreach
(
$tokens
as
$name
=>
$original
)
{
switch
(
$name
)
{
case
'from'
:
$replacements
[
$original
]
=
$config
->
get
(
'smtp_from'
);
break
;
case
'fromname'
:
$replacements
[
$original
]
=
$config
->
get
(
'smtp_fromname'
);
break
;
case
'username'
:
$replacements
[
$original
]
=
$config
->
get
(
'smtp_username'
);
break
;
}
}
}
return
$replacements
;
}
Loading