btcpayserver-greenfield-php/examples/store_email.php
ndeet 72292879fe
Adding new endpoints (#110)
* Adding Store (Users) endpoints.

* Add Store Email endpoints; fix codestyle.

* Adding Store Rates, Rates config, rate sources.

* Add server info example.
2023-05-02 19:26:34 +02:00

61 lines
1.3 KiB
PHP

<?php
require __DIR__ . '/../vendor/autoload.php';
use BTCPayServer\Client\StoreEmail;
// Fill in with your BTCPay Server data.
$apiKey = '';
$host = ''; // e.g. https://your.btcpay-server.tld
$storeId = '';
$server = '';
$port = '';
$username = '';
$password = '';
$fromEmail = '';
$fromName = 'John Doe';
$disableCertificateCheck = false;
$recipient = '';
$subject = 'Testmail from BTCPay';
$body = "Let's see if we can have multiple lines \n\n this should be below. \n\n Enjoy";
// List all store users.
echo "\n List email settings \n";
try {
$client = new StoreEmail($host, $apiKey);
var_dump($client->getSettings($storeId));
} catch (\Throwable $e) {
echo "Error: " . $e->getMessage();
}
// Update store email settings.
echo "\n Update store email settings \n";
try {
$client = new StoreEmail($host, $apiKey);
$updated = $client->updateSettings(
$storeId,
$server,
$port,
$username,
$password,
$fromEmail,
$fromName,
$disableCertificateCheck
);
var_dump($updated);
} catch (\Throwable $e) {
echo "Error: " . $e->getMessage();
}
// Send an email.
echo "\n Send an email. \n:";
try {
$client = new StoreEmail($host, $apiKey);
var_dump($client->sendMail($storeId, $recipient, $subject, $body));
} catch (\Throwable $e) {
echo "Error: " . $e->getMessage();
}