1. Go to this page and download the library: Download utopia-php/messaging library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
utopia-php / messaging example snippets
use \Utopia\Messaging\Messages\Email;
use \Utopia\Messaging\Adapter\Email\SendGrid;
use \Utopia\Messaging\Adapter\Email\Mailgun;
use \Utopia\Messaging\Adapter\Email\Resend;
use \Utopia\Messaging\Adapter\Email\SES;
$message = new Email(
to: ['[email protected]'],
subject: 'Hello World',
content: '<h1>Hello World</h1>'
);
$messaging = new Sendgrid('YOUR_API_KEY');
$messaging->send($message);
$messaging = new Mailgun('YOUR_API_KEY', 'YOUR_DOMAIN');
$messaging->send($message);
$messaging = new Resend('YOUR_API_KEY');
$messaging->send($message);
$messaging = new SES('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY', 'YOUR_REGION');
$messaging->send($message);
use \Utopia\Messaging\Messages\SMS;
use \Utopia\Messaging\Adapter\SMS\Twilio;
use \Utopia\Messaging\Adapter\SMS\Telesign;
$message = new SMS(
to: ['+12025550139'],
content: 'Hello World'
);
$messaging = new Twilio('YOUR_ACCOUNT_SID', 'YOUR_AUTH_TOKEN');
$messaging->send($message);
$messaging = new Telesign('YOUR_USERNAME', 'YOUR_PASSWORD');
$messaging->send($message);
use \Utopia\Messaging\Messages\SMS;
use \Utopia\Messaging\Adapter\SMS\WhatsApp;
use \Utopia\Messaging\Adapter\SMS\WhatsApp\App;
use \Utopia\Messaging\Adapter\SMS\WhatsApp\MetadataParameter;
use \Utopia\Messaging\Adapter\SMS\WhatsApp\OtpType;
$messaging = new WhatsApp('YOUR_ACCESS_TOKEN', 'YOUR_PHONE_NUMBER_ID', 'login_code');
// Copy-code works everywhere. One-tap and zero-tap hand the code straight to a
// named Android app and fall back to copy-code on other platforms.
$messaging->upsertTemplate(
'YOUR_BUSINESS_ACCOUNT_ID',
['en_US', 'fr'],
expirationMinutes: 10,
otpType: OtpType::ONE_TAP,
apps: [new App('com.example.app', 'K8a/AINcGX7')],
);
$messaging->getTemplate('YOUR_BUSINESS_ACCOUNT_ID'); // [['language' => 'en_US', 'status' => 'APPROVED', ...], ...]
$message = new SMS(
to: ['+12025550139'],
content: '482913'
);
$message->setMetadata([
MetadataParameter::LANGUAGE->value => 'fr',
MetadataParameter::TEMPLATE->value => 'recovery_code',
MetadataParameter::CALLBACK_DATA->value => 'token-64f1c2', // echoed back in status webhooks
]);
$messaging->send($message);
use \Utopia\Messaging\Messages\Push;
use \Utopia\Messaging\Adapter\Push\FCM;
$message = new Push(
to: ['eyJhGc...ssw5c'],
content: 'Hello World'
);
$messaging = new FCM('YOUR_SERVICE_ACCOUNT_JSON');
$messaging->send($message);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.