Skip to content

Commit 0e9c897

Browse files
committed
Remove & from rlm_smtp
1 parent f3fd653 commit 0e9c897

File tree

7 files changed

+104
-74
lines changed

7 files changed

+104
-74
lines changed

doc/antora/modules/reference/pages/raddb/mods-available/smtp.adoc

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,21 +323,23 @@ smtp {
323323
}
324324
uri = "smtp://192.0.20.1/"
325325
timeout = 5s
326-
# username_attribute = &User-Name
327-
# password_attribute = &User-Password
326+
authenticate {
327+
# username = User-Name
328+
# password = User-Password
329+
}
328330
# username = "user"
329331
# password = "secret"
330332
template_directory = raddb/mods_config/smtp
331-
attachments = &SMTP-Attachments[*]
333+
attachments = SMTP-Attachments[*]
332334
envelope_address = "postmaster@localhost"
333-
sender_address = &SMTP-Sender-Address[*]
334-
# recipients = &SMTP-Recipients[*]
335-
# recipients = &SMTP-TO[*]
336-
# recipients = &SMTP-CC[*]
337-
# recipients = &SMTP-BCC[*]
338-
# to = &SMTP-TO[*]
339-
# cc = &SMTP-CC[*]
340-
# bcc = &SMTP-BCC[*]
335+
sender_address = SMTP-Sender-Address[*]
336+
# recipients = SMTP-Recipients[*]
337+
# recipients = SMTP-TO[*]
338+
# recipients = SMTP-CC[*]
339+
# recipients = SMTP-BCC[*]
340+
# to = SMTP-TO[*]
341+
# cc = SMTP-CC[*]
342+
# bcc = SMTP-BCC[*]
341343
# set_date = yes
342344
header {
343345
subject = "email subject"

raddb/mods-available/smtp

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,27 @@ smtp {
198198
timeout = 5s
199199

200200
#
201-
# username_attribute:: Which attribute in the request should be used as
202-
# the user's username when performing SMTP authentication.
201+
# authenticate: Configuration for verifying a users name and clear-text password
202+
# against an SMTP server.
203203
#
204-
# username_attribute = &User-Name
204+
# This is not generally recommended, but is supported for cases where an LDAP server
205+
# is not available, and only an SMTP server is available.
206+
#
207+
authenticate {
208+
#
209+
# username:: The users name when performing SMTP authentication.
210+
#
211+
# username = User-Name
212+
213+
#
214+
# password_attribute:: The users password when performing SMTP authentication
215+
#
216+
# password = User-Password
217+
}
205218

206219
#
207-
# password_attribute:: Which attribute in the request should be used as
208-
# the user's password when performing SMTP authentication.
220+
# In most cases, the SMTP module will be used to send email.
209221
#
210-
# password_attribute = &User-Password
211222

212223
#
213224
# username:: User name to use when sending emails. Can be a fixed
@@ -232,7 +243,7 @@ smtp {
232243
# Attachments:: attachments with their relative path from template_directory
233244
# There can be no leading / or ..
234245
#
235-
attachments = &SMTP-Attachments[*]
246+
attachments = SMTP-Attachments[*]
236247

237248
#
238249
# envelope_address:: This is the address used to send the mail,
@@ -242,42 +253,55 @@ smtp {
242253
envelope_address = "postmaster@localhost"
243254

244255
#
245-
# sender_address:: This are the addresses displayed in the FROM: element of the header
246-
# This can be different than the provided envelope_address,
247-
# If envelope_address is set, this can be formatted however you want it to appear to the receiver
248-
# If envelope_address is not set, the first element in sender_address will be used as the envelope address
256+
# sender_address:: Set the body `FROM` address.
257+
#
258+
# This can be different than the provided envelope_address.
259+
#
260+
# If envelope_address is set, this can be formatted however
261+
# you want it to appear to the receiver.
249262
#
250-
sender_address = &SMTP-Sender-Address[*]
263+
# If envelope_address is not set, the first element in
264+
# sender_address will be used as the envelope address.
265+
#
266+
sender_address = SMTP-Sender-Address[*]
251267

252268
#
253269
# recipients:: Email addresses to be set as recipients for the email
254-
# If recipients is set bcc, cc, and to will not be automatically added to the email
255-
# And so they must be included here.
256270
#
257-
# recipients = &SMTP-Recipients[*]
258-
# recipients = &SMTP-TO[*]
259-
# recipients = &SMTP-CC[*]
260-
# recipients = &SMTP-BCC[*]
271+
# If recipients is set, then `bcc`, `cc`, and `to` will not
272+
# be automatically added to the email. Only the list of
273+
# `recipients` will be used.
274+
#
275+
# recipients = SMTP-Recipients[*]
276+
# recipients = SMTP-TO[*]
277+
# recipients = SMTP-CC[*]
278+
# recipients = SMTP-BCC[*]
261279

262280
#
263-
# to:: Email addresses to be set in the TO: header
264-
# These addresses will be added as envelope recipients only if recipients is not set
281+
# to:: Set the body `TO` header.
282+
#
283+
# If `recepients` is not set, then messages will be sent to the `TO` address.
284+
#
285+
# to = SMTP-TO[*]
286+
265287
#
266-
# to = &SMTP-TO[*]
288+
# cc:: Set the body `CC` header.
267289
#
268-
# cc:: Email addresses to be set in the CC: header
269-
# These addresses will be added as envelope recipients only if recipients is not set
290+
# If `recepients` is not set, then messages will also be sent to the `CC` addresses.
270291
#
271-
# cc = &SMTP-CC[*]
292+
# cc = SMTP-CC[*]
272293

273294
#
274-
# bcc:: Comma separated list of emails.
275-
# the local part may contain commas, the domain may not (RFC 2821)
276-
# Therefore, first comma after the @ represents a new address
277-
# not listed in the header of the email
278-
# if recipients is not set, these emails will be added to the envelope recipients
295+
# bcc:: Set the `BCC` recipients.
296+
#
297+
# The local part may contain commas, the domain may not (RFC 2821)
298+
#
299+
# Therefore, the first comma after the @ represents a new
300+
# address, and is not listed in the header of the email.
301+
#
302+
# If `recepients` is not set, then messages will also be sent to the `CCC` addresses.
279303
#
280-
# bcc = &SMTP-BCC[*]
304+
# bcc = SMTP-BCC[*]
281305

282306
#
283307
# set_date:: Adds a Date: to the header, set to the time the request is received

src/modules/rlm_smtp/rlm_smtp.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,17 +1000,17 @@ static const call_env_method_t method_env = {
10001000
{ FR_CALL_ENV_PARSE_OFFSET("username", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_CONCAT, rlm_smtp_env_t, username, username_tmpl),
10011001
.pair.dflt_quote = T_DOUBLE_QUOTED_STRING },
10021002
{ FR_CALL_ENV_OFFSET("password", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_CONCAT, rlm_smtp_env_t, password), .pair.dflt_quote = T_DOUBLE_QUOTED_STRING },
1003-
{ FR_CALL_ENV_OFFSET("sender_address", FR_TYPE_STRING, CALL_ENV_FLAG_NONE, rlm_smtp_env_t, sender_address) },
1004-
{ FR_CALL_ENV_OFFSET("recipients", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE, rlm_smtp_env_t, recipient_addrs),
1005-
.pair.dflt = "&SMTP-Recipients[*]", .pair.dflt_quote = T_BARE_WORD },
1006-
{ FR_CALL_ENV_OFFSET("TO", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE, rlm_smtp_env_t, to_addrs),
1007-
.pair.dflt = "&SMTP-TO[*]", .pair.dflt_quote = T_BARE_WORD },
1008-
{ FR_CALL_ENV_OFFSET("CC", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE, rlm_smtp_env_t, cc_addrs),
1009-
.pair.dflt = "&SMTP-CC[*]", .pair.dflt_quote = T_BARE_WORD },
1010-
{ FR_CALL_ENV_OFFSET("BCC", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE, rlm_smtp_env_t, bcc_addrs),
1011-
.pair.dflt = "&SMTP-BCC[*]", .pair.dflt_quote = T_BARE_WORD },
1012-
{ FR_CALL_ENV_OFFSET("attachments", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE, rlm_smtp_env_t, attachments),
1013-
.pair.dflt = "&SMTP-Attachments[*]", .pair.dflt_quote = T_BARE_WORD },
1003+
{ FR_CALL_ENV_OFFSET("sender_address", FR_TYPE_STRING, CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, sender_address) },
1004+
{ FR_CALL_ENV_OFFSET("recipients", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, recipient_addrs),
1005+
.pair.dflt = "SMTP-Recipients[*]", .pair.dflt_quote = T_BARE_WORD },
1006+
{ FR_CALL_ENV_OFFSET("to", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, to_addrs),
1007+
.pair.dflt = "SMTP-TO[*]", .pair.dflt_quote = T_BARE_WORD },
1008+
{ FR_CALL_ENV_OFFSET("cc", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, cc_addrs),
1009+
.pair.dflt = "SMTP-CC[*]", .pair.dflt_quote = T_BARE_WORD },
1010+
{ FR_CALL_ENV_OFFSET("bcc", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, bcc_addrs),
1011+
.pair.dflt = "SMTP-BCC[*]", .pair.dflt_quote = T_BARE_WORD },
1012+
{ FR_CALL_ENV_OFFSET("attachments", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, attachments),
1013+
.pair.dflt = "SMTP-Attachments[*]", .pair.dflt_quote = T_BARE_WORD },
10141014
{ FR_CALL_ENV_SUBSECTION_FUNC("header", CF_IDENT_ANY, CALL_ENV_FLAG_SUBSECTION, smtp_header_section_parse) },
10151015

10161016
CALL_ENV_TERMINATOR
@@ -1020,12 +1020,16 @@ static const call_env_method_t method_env = {
10201020
static const call_env_method_t auth_env = {
10211021
FR_CALL_ENV_METHOD_OUT(rlm_smtp_auth_env_t),
10221022
.env = (call_env_parser_t[]) {
1023-
{ FR_CALL_ENV_PARSE_OFFSET("username_attribute", FR_TYPE_STRING,
1024-
CALL_ENV_FLAG_ATTRIBUTE | CALL_ENV_FLAG_REQUIRED | CALL_ENV_FLAG_NULLABLE,
1025-
rlm_smtp_auth_env_t, username, username_tmpl), .pair.dflt = "&User-Name", .pair.dflt_quote = T_BARE_WORD },
1026-
{ FR_CALL_ENV_PARSE_OFFSET("password_attribute", FR_TYPE_STRING,
1027-
CALL_ENV_FLAG_ATTRIBUTE | CALL_ENV_FLAG_REQUIRED | CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_SECRET,
1028-
rlm_smtp_auth_env_t, password, password_tmpl), .pair.dflt = "&User-Password", .pair.dflt_quote = T_BARE_WORD },
1023+
{ FR_CALL_ENV_SUBSECTION("authenticate", NULL, CALL_ENV_FLAG_SUBSECTION | CALL_ENV_FLAG_PARSE_MISSING,
1024+
((call_env_parser_t[]) {
1025+
{ FR_CALL_ENV_PARSE_OFFSET("username", FR_TYPE_STRING,
1026+
CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE | CALL_ENV_FLAG_REQUIRED | CALL_ENV_FLAG_NULLABLE,
1027+
rlm_smtp_auth_env_t, username, username_tmpl), .pair.dflt = "User-Name", .pair.dflt_quote = T_BARE_WORD },
1028+
{ FR_CALL_ENV_PARSE_OFFSET("password", FR_TYPE_STRING,
1029+
CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE | CALL_ENV_FLAG_REQUIRED | CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_SECRET,
1030+
rlm_smtp_auth_env_t, password, password_tmpl), .pair.dflt = "User-Password", .pair.dflt_quote = T_BARE_WORD },
1031+
CALL_ENV_TERMINATOR
1032+
}))},
10291033
CALL_ENV_TERMINATOR
10301034
}
10311035
};

src/tests/modules/smtp/module.conf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ smtp {
3232
template_directory = "$ENV{top_srcdir}build/ci/exim4"
3333

3434
envelope_address = "postmaster@localhost"
35-
attachments = &SMTP-Attachments[*]
35+
attachments = SMTP-Attachments[*]
3636

3737
recipients = "conf_recipient_1@localhost"
3838
recipients = "conf_recipient_2@localhost"
39-
recipients = &SMTP-Recipients[*]
40-
recipients = &SMTP-TO[*]
41-
recipients = &SMTP-CC[*]
39+
recipients = SMTP-Recipients[*]
40+
recipients = SMTP-TO[*]
41+
recipients = SMTP-CC[*]
4242

43-
TO = "conf_to@localhost"
44-
TO = &SMTP-TO[*]
43+
to = "conf_to@localhost"
44+
to = SMTP-TO[*]
4545

46-
CC = &SMTP-CC[*]
46+
cc = SMTP-CC[*]
4747

4848
set_date = no
4949
}

src/tests/modules/smtp/smtp_attachment/module.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ smtp {
3333

3434
recipients = "conf_recipient_1@localhost"
3535
recipients = "conf_recipient_2@localhost"
36-
recipients = &SMTP-Recipients[*]
36+
recipients = SMTP-Recipients[*]
3737

38-
TO = "conf_to@localhost"
39-
TO = &SMTP-TO[*]
38+
to = "conf_to@localhost"
39+
to = SMTP-TO[*]
4040

41-
CC = &SMTP-CC[*]
41+
cc = SMTP-CC[*]
4242

4343
set_date = no
4444
}

src/tests/modules/smtp/smtp_crln/module.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ smtp {
3030
sender_address = "sender_email2@localhost"
3131
envelope_address = "postmaster@localhost"
3232
recipients = "crln_test_receiver@localhost"
33-
recipients = &SMTP-Recipients[*]
33+
recipients = SMTP-Recipients[*]
3434
set_date = no
3535
}
3636

src/tests/modules/smtp/smtp_stringparse/module.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ smtp {
2323
message_id = "123456789@example.com"
2424
}
2525

26-
username = &User-Name
27-
password = &User-Password
26+
username = "%{User-Name}"
27+
password = "%{User-Password}"
2828

2929
uri = "$ENV{SMTP_TEST_SERVER}:$ENV{SMTP_TEST_SERVER_PORT}"
3030
timeout = 5s
3131
template_directory = "$ENV{top_srcdir}build/ci/exim4"
32-
sender_address = &SMTP-Sender-Address[*]
32+
sender_address = SMTP-Sender-Address[*]
3333
envelope_address = "postmaster@localhost"
3434
recipients = "conf-stringparse-recipient@localhost"
35-
recipients = &SMTP-Recipients[*]
35+
recipients = SMTP-Recipients[*]
3636
set_date = no
3737
}
3838

0 commit comments

Comments
 (0)