ProxiedMail provides an API to create email address and receive any incoming messages straight to your application within the simple composer package.
Here in this example you can see how to receive sent email to your API. The program will print email address created to receive your email message.
<?php | |
use ProxiedMail\Client\Bridge\ProxiedMailClient; | |
use ProxiedMail\Client\Facades\ApiFacade; | |
class ExampleController | |
{ | |
public function browseReceivedEmails(ProxiedMailClient $proxiedMailClient) | |
{ | |
/** | |
* @var ApiFacade $api | |
*/ | |
$api = $proxiedMailClient->getClient(); | |
$proxyEmail = $api->createProxyEmail( | |
[], | |
null, | |
null, | |
null, | |
true | |
); | |
// while (true) with 100 seconds limit | |
foreach (range(0, 180) as $non) { | |
echo "PROXY-EMAIL: " . $proxyEmail->getProxyAddress() . "\n"; | |
echo "Time limit is 3 mins \n"; | |
echo "Send the email to this proxy-email to get email payload printed here \n"; | |
//checking webhook receiver | |
$receivedEmails = $api->getReceivedEmailsLinksByProxyEmailId($proxyEmail->getId())->getReceivedEmailLinks(); | |
echo "Amount of received emails: " . count($receivedEmails) . "\n"; | |
foreach ($receivedEmails as $receivedEmail) { | |
echo "Have received email: \n"; | |
var_dump($receivedEmail); | |
echo "\n"; | |
} | |
echo "\n"; | |
sleep(1); | |
} | |
} | |
public function receiveEmailViaWebhook(ProxiedMailClient $proxiedMailClient) | |
{ | |
/** | |
* @var ApiFacade $api | |
*/ | |
$api = $proxiedMailClient->getClient(); | |
$wh = $api->createWebhook(); //creating webhook-receiver | |
$proxyEmail = $api->createProxyEmail( | |
[], | |
null, | |
$wh->getCallUrl() //specifying webhook url | |
); | |
// while (true) with 100 seconds limit | |
foreach (range(0, 100) as $non) { | |
echo "PROXY-EMAIL: " . $proxyEmail->getProxyAddress() . "\n"; | |
echo "Send the email to this proxy-email to get email payload printed here"; | |
//checking webhook receiver | |
$whStatus = $api->statusWebhook($wh->getId()); | |
echo "Webhook STATUS: \n"; | |
echo "Received: " . ($whStatus->isReceived() ? 'yes' : 'no') . "\n"; //printing webhook status | |
//printing payload if received | |
if ($whStatus->isReceived()) { | |
echo "WEBHOOK PAYLOAD: \n"; | |
echo json_encode($whStatus->getPayload()); | |
break; | |
} | |
echo "\n"; | |
sleep(1); | |
} | |
} | |
} |
Please see more on GitHub or docs
Start receiving emails via webhooks/callbacks to your system. We will send you all information about your email including attachments and headers.
Receive webhooks on emails sent to your custom domain if you able to set up MX records for it.
Check out our documentation to know how to build your app in a proper way.