Created
January 22, 2019 04:05
-
-
Save michaellopez/d087d047acee4d76bcc8fe16b9102d95 to your computer and use it in GitHub Desktop.
Patch that adds return_path / envelope FROM to Sparkpost Drupal module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/config/install/sparkpost.settings.yml b/config/install/sparkpost.settings.yml | |
index e014059..504215a 100644 | |
--- a/config/install/sparkpost.settings.yml | |
+++ b/config/install/sparkpost.settings.yml | |
@@ -2,6 +2,7 @@ api_key: | |
debug: true | |
sender: | |
sender_name: | |
+return_path: | |
format: '' | |
async: false | |
skip_cron: false | |
diff --git a/config/schema/sparkpost.schema.yml b/config/schema/sparkpost.schema.yml | |
index 0078d20..0e7e50e 100644 | |
--- a/config/schema/sparkpost.schema.yml | |
+++ b/config/schema/sparkpost.schema.yml | |
@@ -14,6 +14,9 @@ sparkpost.settings: | |
sender_name: | |
type: text | |
label: 'Sender name' | |
+ return_path: | |
+ type: text | |
+ label: 'Return path' | |
format: | |
label: 'Format to format message' | |
type: text | |
diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php | |
index 58e2674..4497de5 100644 | |
--- a/src/Form/SettingsForm.php | |
+++ b/src/Form/SettingsForm.php | |
@@ -100,6 +100,12 @@ class SettingsForm extends ConfigFormBase { | |
'#default_value' => $config->get('sender_name'), | |
'#description' => $this->t('Optionally enter a from name to be used.'), | |
]; | |
+ $form['options']['return_path'] = [ | |
+ '#type' => 'textfield', | |
+ '#title' => $this->t('Return path'), | |
+ '#default_value' => $config->get('return_path'), | |
+ '#description' => $this->t('Optionally enter an email address to use for envelope FROM.') | |
+ ]; | |
$options = ['' => $this->t('-- Select --')]; | |
$formats = filter_formats(); | |
foreach ($formats as $key => $format) { | |
@@ -146,6 +152,7 @@ class SettingsForm extends ConfigFormBase { | |
->set('debug', $form_state->getValue('debug')) | |
->set('sender_name', $form_state->getValue('sender_name')) | |
->set('sender', $form_state->getValue('sender')) | |
+ ->set('return_path', $form_state->getValue('return_path')) | |
->set('format', $form_state->getValue('format')) | |
->set('async', $form_state->getValue('async')) | |
->set('skip_cron', $form_state->getValue('skip_cron')) | |
diff --git a/src/Plugin/Mail/SparkpostMail.php b/src/Plugin/Mail/SparkpostMail.php | |
index 455d4bf..718c741 100644 | |
--- a/src/Plugin/Mail/SparkpostMail.php | |
+++ b/src/Plugin/Mail/SparkpostMail.php | |
@@ -124,6 +124,7 @@ class SparkpostMail implements MailInterface { | |
'options' => [ | |
'transactional' => TRUE, | |
], | |
+ 'return_path' => $this->config->get('return_path') | |
]; | |
// @todo: Handle response in some way. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment