-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from nswdpc/cherrypick-from-taggable
Improvements from tagging work
- Loading branch information
Showing
17 changed files
with
1,034 additions
and
408 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,50 +8,61 @@ | |
|
||
MailgunEmail extends Email and provides added features for use with Mailgun via `setCustomParameters` | ||
|
||
These extra options, variables, headers and recipient variables are passed to the Mailgun API | ||
These extra options, variables, headers and recipient variables are passed to the Mailgun API. | ||
|
||
```php | ||
use SilverStripe\Control\Email\Email; | ||
|
||
$email = Email::create(); | ||
|
||
// add standard email to, cc etc | ||
|
||
// add custom params for Mailgun: | ||
|
||
$variables = [ | ||
'test' => 'true', | ||
'foo' => 'bar', | ||
]; | ||
|
||
$options = [ | ||
'testmode' => 'yes', | ||
'tag' => ['tag1','tag2','tag4'], | ||
'tracking' => 'yes', // test tracking turn on | ||
'require-tls' => 'yes' | ||
$person = get_person(); | ||
|
||
// Set parameters (no need to prefix keys) | ||
$parameters = [ | ||
|
||
// Set v: prefixed variables | ||
'variables' => [ | ||
'test' => 'true', | ||
'foo' => 'bar', | ||
], | ||
|
||
// Set o: prefixed options | ||
'options' => [ | ||
'deliverytime' => $person->getReminderTime(\DateTimeInterface::RFC2822), | ||
'dkim' => 'yes',// require DKIM for this specific message | ||
'tag' => ['tag1','tag2','tag4'], // send some tags for analytics | ||
'tracking' => 'yes', // turn tracking on just for this message | ||
'require-tls' => 'yes', // require a TLS connection when Mailgun connects to the remote mail server | ||
'skip-verification' => 'no' // do not skip TLS verification | ||
], | ||
|
||
// h: prefixed headers | ||
'headers' => [ | ||
'X-Test-Header' => 'testing' | ||
], | ||
|
||
// Specific recipient variables | ||
'recipient_variables' => [ | ||
$person->Email => ["tagline" => "Reminder"] | ||
] | ||
]; | ||
|
||
$headers = [ | ||
'X-Test-Header' => 'testing' | ||
]; | ||
// Send the email | ||
$email = Email::create(); | ||
$email->setTo($person->Email) | ||
->setSubject('A reminder') | ||
->setFrom('[email protected]') | ||
->setCustomParameters($parameters) | ||
->send(); | ||
``` | ||
|
||
$recipient_variables = [ | ||
$to_address => ["unique_id" => "testing_123"] | ||
]; | ||
## Tagging | ||
|
||
$email->setCustomParameters([ | ||
'options' => $options, | ||
'variables' => $variables, | ||
'headers' => $headers, | ||
'recipient-variables' => $recipient_variables | ||
]); | ||
To set tags on a message, include them in the `$parameters['options']['tag']` array. | ||
|
||
$email->send(); | ||
``` | ||
[Mailgun places a limit of 3 tags per message](https://documentation.mailgun.com/en/latest/user_manual.html#tagging). | ||
|
||
## Future delivery | ||
|
||
To send in the future, use [scheduled delivery](https://documentation.mailgun.com/en/latest/user_manual.html#scheduling-delivery) | ||
To send in the future, use [scheduled delivery](https://documentation.mailgun.com/en/latest/user_manual.html#scheduling-delivery) with an RFC2822 formatted datetime. | ||
|
||
```php | ||
//send in the future example | ||
|
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.