1. Go to this page and download the library: Download ojessecruz/resend-inbox 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/ */
ojessecruz / resend-inbox example snippets
use Jessecruz\ResendInbox\Exceptions\InvalidWebhook;
use Jessecruz\ResendInbox\Webhook\DeliveryStatusChanged;
use Jessecruz\ResendInbox\Webhook\EmailReceived;
use Jessecruz\ResendInbox\Webhook\WebhookParser;
$parser = new WebhookParser($signingSecret); // "whsec_..." from the Resend dashboard
try {
$event = $parser->parse($rawBody, $requestHeaders);
} catch (InvalidWebhook) {
// respond 401 / 400
}
match (true) {
$event instanceof EmailReceived => $queue->push($event->emailId),
$event instanceof DeliveryStatusChanged => $store->recordStatus($event),
default => null,
};
use Jessecruz\ResendInbox\Mailbox;
use Jessecruz\ResendInbox\ResendMailbox;
use Jessecruz\ResendInbox\Threading\ThreadResolver;
$mailbox = new Mailbox('example.com', ['[email protected]', '[email protected]'], 'Example Team');
$resend = new ResendMailbox(\Resend::client($apiKey));
$email = $resend->receivedEmail($emailId);
if (! $mailbox->hasOwnRecipient($email->recipients())) {
return; // addressed to another domain on the same Resend account
}
$threadId = (new ThreadResolver($lookup))->resolveFor($email); // null: start a new conversation
$address = $mailbox->mailboxFor($email->recipients()); // which of our addresses received it
$notify = ! $email->isAutoGenerated();
use Jessecruz\ResendInbox\Composing\Conversation;
use Jessecruz\ResendInbox\Composing\ReplyBuilder;
$composed = (new ReplyBuilder($mailbox))->build(
from: '[email protected]',
to: ['[email protected]'],
subject: 'Re: Pricing',
markdown: "Hi Maria,\n\n...",
conversation: new Conversation($storedMessageIds, $latestMessageId, $mailboxesThatReceivedMail),
);
$resendId = $resend->send($composed->email);
// store $composed->messageId, ->inReplyTo and ->references with the message
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.