-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
489 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,8 +162,7 @@ Link component adds an anchor tag. This is the same as a text component with the | |
|
||
```php | ||
Content::builder() | ||
->link("Confirm Email", "https://example.com/confirm?token=XYZ") // or... | ||
->text("[Confirm Email](https://example.com/confirm?token=XYZ)") | ||
->link("Confirm Email", "https://example.com/confirm?token=XYZ") | ||
->build(); | ||
``` | ||
|
||
|
@@ -252,6 +251,8 @@ Content::builder() | |
new SocialItem(Service::SNAPCHAT, "Username"), | ||
new SocialItem(Service::THREADS, "Username"), | ||
new SocialItem(Service::TELEGRAM, "Username"), | ||
new SocialItem(Service::MASTODON, "@[email protected]"), | ||
new SocialItem(Service::RSS, "https://example.com/blog"), | ||
]) | ||
->build(); | ||
``` | ||
|
@@ -271,6 +272,92 @@ Content::builder() | |
->build(); | ||
``` | ||
|
||
</details> | ||
<details><summary>Store Badges</summary> | ||
|
||
Link to your mobile apps via store badges: | ||
|
||
```php | ||
Content::builder() | ||
->store_badges([ | ||
new StoreBadgeItem(StoreBadge::APP_STORE, "https://apps.apple.com/us/app/example/id1234567890"), | ||
new StoreBadgeItem(StoreBadge::GOOGLE_PLAY, "https://play.google.com/store/apps/details?id=com.example"), | ||
new StoreBadgeItem(StoreBadge::MICROSOFT_STORE, "https://apps.microsoft.com/detail/example"), | ||
]) | ||
->build(); | ||
``` | ||
|
||
</details> | ||
<details><summary>QR Code</summary> | ||
|
||
You can also generate QR codes on the fly. They will be shown as images inside the email. | ||
|
||
Here are all the supported data types: | ||
|
||
```php | ||
// url | ||
Content::builder() | ||
->qr_code("https://example.com") | ||
->build(); | ||
|
||
Content::builder() | ||
->component(QrCode::email("[email protected]")) | ||
->build(); | ||
|
||
// phone | ||
Content::builder() | ||
->component(QrCode::phone("123-456-7890")) | ||
->build(); | ||
|
||
// sms / text message | ||
Content::builder() | ||
->component(QrCode::sms("123-456-7890")) | ||
->build(); | ||
|
||
// geo coordinates | ||
Content::builder() | ||
->component(QrCode::coordinates(37.773972, -122.431297)) | ||
->build(); | ||
|
||
// crypto address (for now only Bitcoin and Ethereum are supported) | ||
Content::builder() | ||
->component(QrCode::cryptocurrencyAddress(Cryptocurrency::BITCOIN, "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa")) | ||
->build(); | ||
|
||
// you can also encode any binary data | ||
Content::builder() | ||
->component(new QrCode(implode(array_map(function($byte) { return chr($byte); }, [1, 2, 3])))) | ||
->build(); | ||
``` | ||
|
||
</details> | ||
<details><summary>Signature</summary> | ||
|
||
Generated signatures can be added to your emails to give a bit of a personal touch. This will embed an image with your custom text using one of several available fonts: | ||
|
||
```php | ||
// signature with a default font | ||
Content::builder() | ||
->signature("John Smith") | ||
->build(); | ||
|
||
// signature with a custom font | ||
Content::builder() | ||
->component("John Smith", SignatureFont::REENIE_BEANIE) | ||
->build(); | ||
``` | ||
|
||
These are the available fonts: | ||
|
||
- `SignatureFont::REENIE_BEANIE` [preview →](https://fonts.google.com/specimen/Reenie+Beanie) | ||
- `SignatureFont::MEOW_SCRIPT` [preview →](https://fonts.google.com/specimen/Meow+Script) | ||
- `SignatureFont::CAVEAT` [preview →](https://fonts.google.com/specimen/Caveat) | ||
- `SignatureFont::ZEYADA` [preview →](https://fonts.google.com/specimen/Zeyada) | ||
- `SignatureFont::PETEMOSS` [preview →](https://fonts.google.com/specimen/Petemoss) | ||
|
||
Signature should not exceed 64 characters. Only alphanumeric characters and most common symbols are allowed. | ||
|
||
</details> | ||
|
||
--- | ||
|
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
require_once './vendor/autoload.php'; | ||
|
||
use Templateless\Content; | ||
use Templateless\Email; | ||
use Templateless\EmailAddress; | ||
use Templateless\Templateless; | ||
use Templateless\Collection; | ||
use Templateless\Theme; | ||
use Templateless\Components\SocialItem; | ||
use Templateless\Components\Service; | ||
use Templateless\Components\StoreBadgeItem; | ||
use Templateless\Components\StoreBadge; | ||
|
||
try { | ||
$api_key = $env["TEMPLATELESS_API_KEY"] ?? getenv("TEMPLATELESS_API_KEY"); | ||
if (!isset($api_key) || $api_key == '') { | ||
echo "Set TEMPLATELESS_API_KEY to your Templateless API key"; | ||
exit; | ||
} | ||
|
||
$email_address = $env["TEMPLATELESS_EMAIL_ADDRESS"] ?? getenv("TEMPLATELESS_EMAIL_ADDRESS"); | ||
if (!isset($email_address) || $email_address == '') { | ||
echo "Set TEMPLATELESS_EMAIL_ADDRESS to your own email address"; | ||
exit; | ||
} | ||
|
||
$header = Collection::builder() | ||
->image('https://templateless.net/myco.webp', null, 100, null, 'MyCo') | ||
->build(); | ||
|
||
$app_store_link = "https://apps.apple.com/us/app/example/id1234567890"; | ||
$google_play_link = "https://play.google.com/store/apps/details?id=com.example"; | ||
|
||
$footer = Collection::builder() | ||
->store_badges([ | ||
new StoreBadgeItem(StoreBadge::APP_STORE, $app_store_link), | ||
new StoreBadgeItem(StoreBadge::GOOGLE_PLAY, $google_play_link), | ||
]) | ||
->socials([ | ||
new SocialItem(Service::TWITTER, 'MyCo'), | ||
new SocialItem(Service::GITHUB, 'MyCo'), | ||
]) | ||
->build(); | ||
|
||
$content = Content::builder() | ||
->theme(Theme::SIMPLE) | ||
->header($header) | ||
->text("Hey Alex,") | ||
->text("Thank you for choosing MyCo! To get started with our mobile experience, simply pair your account with our mobile app.") | ||
->text("Here's how to do it:") | ||
->text(implode("\n", [ | ||
"1. Download the MyCo app from the [App Store]($app_store_link) or [Google Play]($google_play_link).", | ||
"1. Open the app and select _Pair Device_.", | ||
"1. Scan the QR code below with your mobile device:", | ||
])) | ||
->qr_code("https://example.com/qr-code-link") | ||
->text("Enjoy your seamless experience across devices!") | ||
->footer($footer) | ||
->build(); | ||
|
||
$email = Email::builder() | ||
->to(new EmailAddress($email_address)) | ||
->subject("How to Pair Device") | ||
->content($content) | ||
->build(); | ||
|
||
$templateless = new Templateless($api_key); | ||
$templateless->send($email); | ||
} catch (\Exception $e) { | ||
echo $e; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
require_once './vendor/autoload.php'; | ||
|
||
use Templateless\Content; | ||
use Templateless\Email; | ||
use Templateless\EmailAddress; | ||
use Templateless\Templateless; | ||
use Templateless\Collection; | ||
use Templateless\Theme; | ||
use Templateless\Components\SocialItem; | ||
use Templateless\Components\Service; | ||
|
||
try { | ||
$api_key = $env["TEMPLATELESS_API_KEY"] ?? getenv("TEMPLATELESS_API_KEY"); | ||
if (!isset($api_key) || $api_key == '') { | ||
echo "Set TEMPLATELESS_API_KEY to your Templateless API key"; | ||
exit; | ||
} | ||
|
||
$email_address = $env["TEMPLATELESS_EMAIL_ADDRESS"] ?? getenv("TEMPLATELESS_EMAIL_ADDRESS"); | ||
if (!isset($email_address) || $email_address == '') { | ||
echo "Set TEMPLATELESS_EMAIL_ADDRESS to your own email address"; | ||
exit; | ||
} | ||
|
||
$header = Collection::builder() | ||
->image('https://templateless.net/myco.webp', null, 100, null, 'MyCo') | ||
->build(); | ||
|
||
$footer = Collection::builder() | ||
->text("If you did not sign up for a MyCo account, please ignore this email.\nThis link will expire in 24 hours.") | ||
->socials([ | ||
new SocialItem(Service::TWITTER, 'MyCo'), | ||
new SocialItem(Service::GITHUB, 'MyCo'), | ||
]) | ||
->link('Unsubscribe', 'https://example.com') | ||
->build(); | ||
|
||
$verify_email_link = 'https://example.com/verify?token=ABC'; | ||
|
||
$content = Content::builder() | ||
->theme(Theme::SIMPLE) | ||
->header($header) | ||
->text("Hi there,") | ||
->text("Welcome to **MyCo**! We're excited to have you on board. Before we get started, we need to verify your email address.") | ||
->text("Please confirm your email by clicking the button below:") | ||
->button("Verify Email", $verify_email_link) | ||
->text("Or use the link below:") | ||
->link($verify_email_link, $verify_email_link) | ||
->footer($footer) | ||
->build(); | ||
|
||
$email = Email::builder() | ||
->to(new EmailAddress($email_address)) | ||
->subject("Confirm your email") | ||
->content($content) | ||
->build(); | ||
|
||
$templateless = new Templateless($api_key); | ||
$templateless->send($email); | ||
} catch (\Exception $e) { | ||
echo $e; | ||
} |
Oops, something went wrong.