Skip to content

Commit 1b33eed

Browse files
committed
Add replyto attribute
Thanks, René.
1 parent 015d1aa commit 1b33eed

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

CHANGELOG.textile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
h1. Changelog
22

3+
h2. 4.7.1 - 2024-02-28
4+
5+
* Use self-closing tags to keep validators happy (thanks, jools-r).
6+
* Fix for concatenated headers/line endings on some servers (thanks, hidalgo, Kjeld, Gallex, and phiw13).
7+
* Add @replyto@ attribute.
8+
39
h2. 4.7.0 - 2022-01-28
410

511
* Fix a few PHP 8.x warnings.

README.textile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ h4. Attributes
193193
: Set to 0 if you wish to stop the browser from validating form field values and 'required' status of input elements. The plugin itself is then solely responsible for validation and will indicate error conditions after submission. Default is @1@.
194194
; @redirect="URL"@
195195
: Redirect to specified URL (overrides @thanks@ and @thanks_form@ attributes). URL must be relative to the Textpattern site URL. Example: @redirect="monkey"@ would redirect to @http://example.com/monkey@.
196+
; @replyto=boolean|email address@
197+
: Governs the email address of who the message reply should go to. Options:
198+
: @true@ (default): Use the email address from the form itself (value from the @<txp:com_connect_email>@ tag) if the @from@ address has been specified. Blank otherwise.
199+
: @false@: Always use the @from@ email address as reply-to. Note that if the @from@ is omitted the email will be from nobody and may be rejected by the receiving server.
200+
: @email address@: Use the specified email address as the reply-to, if it's a valid address.
196201
; @required="boolean"@
197202
: Whether to require all tags in this contact form to be completed before the form can be submitted. Can be overridden on a field-by-field basis by using the @required@ attribute in the relevant tag. Available values: @1@ (yes) or @0@ (no). Default is @1@.
198203
; @send_article="boolean"@

com_connect.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ function com_connect($atts, $thing = '')
317317
'label' => null,
318318
'browser_validate' => 1,
319319
'redirect' => '',
320+
'replyto' => true,
320321
'required' => '1',
321322
'show_error' => 1,
322323
'show_input' => 1,
@@ -532,8 +533,18 @@ function com_connect($atts, $thing = '')
532533
$com_connect_flags['charset'] = $override_email_charset ? 'ISO-8859-1' : 'UTF-8';
533534
$com_connect_flags['content_type'] = 'text/plain';
534535
$com_connect_flags['xfer_encoding'] = '8bit';
535-
$reply = com_connect_strip($from ? $com_connect_from : '');
536-
$from = com_connect_strip($from ? $from : $com_connect_from);
536+
537+
if ($replyto === true) {
538+
$reply = com_connect_strip($from ? $com_connect_from : '');
539+
$from = com_connect_strip($from ? $from : $com_connect_from);
540+
} elseif ($replyto === false || !is_valid_email($replyto)) {
541+
$reply = com_connect_strip($from ? $from : '');
542+
$from = com_connect_strip($from ? $from : '');
543+
} else {
544+
$reply = com_connect_strip($replyto);
545+
$from = com_connect_strip($from ? $from : $replyto);
546+
}
547+
537548
$to = com_connect_strip($to);
538549
$subject = com_connect_strip($subject);
539550
$body = implode("\n\n", $msg);
@@ -2344,6 +2355,11 @@ function com_connect_fields($atts, $thing = '')
23442355
: Set to 0 if you wish to stop the browser from validating form field values and 'required' status of input elements. The plugin itself is then solely responsible for validation and will indicate error conditions after submission. Default is @1@.
23452356
; @redirect="URL"@
23462357
: Redirect to specified URL (overrides @thanks@ and @thanks_form@ attributes). URL must be relative to the Textpattern site URL. Example: @redirect="monkey"@ would redirect to @http://example.com/monkey@.
2358+
; @replyto=boolean|email address@
2359+
: Governs the email address of who the message reply should go to. Options:
2360+
: @true@ (default): Use the email address from the form itself (value from the @<txp:com_connect_email>@ tag) if the @from@ address has been specified. Blank otherwise.
2361+
: @false@: Always use the @from@ email address as reply-to. Note that if the @from@ is omitted the email will be from nobody and may be rejected by the receiving server.
2362+
: @email address@: Use the specified email address as the reply-to, if it's a valid address.
23472363
; @required="boolean"@
23482364
: Whether to require all tags in this contact form to be completed before the form can be submitted. Can be overridden on a field-by-field basis by using the @required@ attribute in the relevant tag. Available values: @1@ (yes) or @0@ (no). Default is @1@.
23492365
; @send_article="boolean"@

0 commit comments

Comments
 (0)