Skip to content

Commit e8ca032

Browse files
Reply to field (#184)
1 parent d24b632 commit e8ca032

File tree

7 files changed

+43
-1
lines changed

7 files changed

+43
-1
lines changed

includes/admin.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ public function ajax_send_test()
415415
$useAPI = (defined('MAILGUN_USEAPI') && MAILGUN_USEAPI) ? MAILGUN_USEAPI : $this->get_option('useAPI');
416416
$secure = (defined('MAILGUN_SECURE') && MAILGUN_SECURE) ? MAILGUN_SECURE : $this->get_option('secure');
417417
$sectype = (defined('MAILGUN_SECTYPE') && MAILGUN_SECTYPE) ? MAILGUN_SECTYPE : $this->get_option('sectype');
418+
$replyTo = (defined('MAILGUN_REPLY_TO_ADDRESS') && MAILGUN_REPLY_TO_ADDRESS) ? MAILGUN_REPLY_TO_ADDRESS : $this->get_option('reply_to');
418419

419420
if (!$getRegion) {
420421
mg_api_last_error(__("Region has not been selected", "mailgun"));
@@ -448,12 +449,17 @@ public function ajax_send_test()
448449
}
449450

450451
try {
452+
$headers = [
453+
'Content-Type: text/plain',
454+
'Reply-To: ' . $replyTo,
455+
];
456+
451457
$result = wp_mail(
452458
$admin_email,
453459
__('Mailgun WordPress Plugin Test', 'mailgun'),
454460
sprintf(__("This is a test email generated by the Mailgun WordPress plugin.\n\nIf you have received this message, the requested test has succeeded.\n\nThe sending region is set to %s.\n\nThe method used to send this email was: %s.",
455461
'mailgun'), $region, $method),
456-
['Content-Type: text/plain']
462+
$headers
457463
);
458464
} catch (Throwable $throwable) {
459465
//Log purpose

includes/options-page.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
$mailgun_from_address_const = ((defined('MAILGUN_FROM_ADDRESS') && MAILGUN_FROM_ADDRESS) ? MAILGUN_FROM_ADDRESS : null);
4646
$mailgun_from_address = $mailgun_from_address_const ?: $this->get_option('from-address');
4747

48+
$mailgunReplyToAddressConst = ((defined('MAILGUN_REPLY_TO_ADDRESS') && MAILGUN_REPLY_TO_ADDRESS) ? MAILGUN_REPLY_TO_ADDRESS : null);
49+
$mailgunReplyTo = $mailgunReplyToAddressConst ?: $this->get_option('reply_to');
50+
4851
$mailgun_secure_const = (defined('MAILGUN_SECURE') ? MAILGUN_SECURE : null);
4952
$mailgun_secure = !is_null($mailgun_secure_const) ? ((string)(1 * $mailgun_secure_const)) : $this->get_option('secure');
5053

@@ -318,6 +321,24 @@ class="regular-text"
318321
</p>
319322
</td>
320323
</tr>
324+
<tr>
325+
<th scope="row">
326+
<?php _e('Reply To Address', 'mailgun'); ?>
327+
</th>
328+
<td>
329+
<input type="text"
330+
class="regular-text"
331+
name="mailgun[reply_to]"
332+
value="<?php esc_attr_e($mailgunReplyTo); ?>"
333+
placeholder="[email protected]"
334+
/>
335+
<p class="description">
336+
<?php
337+
_e('Reply-to address', 'mailgun');
338+
?>
339+
</p>
340+
</td>
341+
</tr>
321342
<tr valign="top">
322343
<th scope="row">
323344
<?php _e('From Name', 'mailgun'); ?>

includes/wp-mail-api.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,11 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
396396
}
397397
}
398398

399+
$replyTo = (defined('MAILGUN_REPLY_TO_ADDRESS') && MAILGUN_REPLY_TO_ADDRESS) ? MAILGUN_REPLY_TO_ADDRESS : get_option('reply_to');
400+
if (!empty($replyTo)) {
401+
$headers['Reply-To'] = $replyTo;
402+
}
403+
399404
// Set custom headers
400405
if (!empty($headers)) {
401406
foreach ((array)$headers as $name => $content) {

languages/mailgun-de_DE.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,6 @@ msgstr ""
204204
#: includes/options-page.php:74
205205
msgid "Save Changes"
206206
msgstr "Änderungen speichern"
207+
208+
msgid "Reply-to address"
209+
msgstr "Antwortadresse"

languages/mailgun-es_ES.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,6 @@ msgstr ""
205205
#: includes/options-page.php:74
206206
msgid "Save Changes"
207207
msgstr "Guardar cambios"
208+
209+
msgid "Reply-to address"
210+
msgstr "dirección de respuesta"

languages/mailgun-pt_BR.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,6 @@ msgstr ""
363363
#. Author URI of the plugin/theme
364364
msgid "http://www.mailgun.com/"
365365
msgstr ""
366+
367+
msgid "Reply-to address"
368+
msgstr ""

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ MAILGUN_FROM_NAME Type: string
6666
MAILGUN_FROM_ADDRESS Type: string
6767
MAILGUN_TRACK_CLICKS Type: string Choices: 'yes' or 'no'
6868
MAILGUN_TRACK_OPENS Type: string Choices: 'yes' or 'no'
69+
MAILGUN_REPLY_TO_ADDRESS Type: string
6970
```
7071

7172
- What hooks are available for use with other plugins?

0 commit comments

Comments
 (0)