<-- All posts

How to receive email with Laravel

How to receive email with Laravel


Meet Alex, the sole brain behind ProxiedMail, a groundbreaking tool revolutionizing the email experience.

ProxiedMail operates on the principle of prioritizing privacy, offering users the ability to generate a unique email address for each interaction, essentially serving as a second password. This approach not only bolsters security but also grants users greater control over their correspondence. Moreover, ProxiedMail facilitates seamless migration to alternate email providers within seconds.

Beyond its core functionality, ProxiedMail aspires to enrich the email development landscape. One key aspect involves integrating email communication directly into applications.
Whether interfacing with systems lacking APIs but supporting email notifications or incorporating user-generated emails into functionality, the possibilities are vast. In this article, I'll elucidate how this can be accomplished using Laravel.

How it works

You can create an email address on ProxiedMail with a specific name or use an autogenerated one. Normally we also forward incoming emails to some kind of real email. Real email is some kind of old-fashioned mailbox on Gmail, ProtonMail, etc.
So, usually, it looks like that abc@proxiedmail.com -> blabla@protonmail.com.
Meanwhile, if you set up a webhook email we also send you a webhook to the specified email. You can disable forwarding to your real email using one of the internal forwarding emails like *@proxiedmail-int.int (i.e testingadw@proxiedmail-int.int)

API Features

  1. Creating endless proxy emails with one of ProxiedMail domains (i.e abc@proxiedmail.com, abcd@pxdmail.com, abcde@pxdmail.net)
  2. Setting up forwarding email or disabling forwarding
  3. Setting up a callback to your URL
  4. Browsing received emails on the received emails endpoint
  5. Setting up custom domains. You can do everything using your domain as well.
  6. Domain-to-domain forwarding. Just in case you need it we can forward emails by mask, like @domainhostedatproxiedmail.com -> someotherdomain.com. In this case, the MX of the first domain should be pointed to ProxiedMail and the second domain should be verified by TXT record.

Let's start

Follow this easy instruction to start receiving emails into your Laravel application.

  1. Sign up on ProxiedMail
  2. Create your API Key
  3. Install the composer library into your application.

composer require proxiedmail/laravel-receive-email

You can find this library on GitHub: https://github.com/proxied-mail/laravel-receive-email

After installation config-file are going to be created automatically if auto-discovery is enabled. If Laravel package auto-discovery is disabled, add service providers manually to /config/app.php. There are service provider you must add:


Publish client configuration

php artisan vendor:publish --tag=proxiedmail

Put your ProxiedMail API token in /config/proxiedmail.php. You can find this token in ProxiedMail API Settings.

return [
    'apiToken' => 'YOUR API TOKEN',
    'host' => 'https://proxiedmail.com',

Start coding.

This example covers both webhook and browsing received emails implementation. Let's say we've created t.php file with the following contents:

Payload example

All of our examples contain a payload. Example of email payload:

      "Content-Type":"multipart\/alternative; boundary=\"000000000000714564060f56f6c2\"",
      "Date":"Sat, 20 Jan 2024 02:00:25 +0000",
      "From":"Alex Yatsenko <sender@gmail.com>",
      "Received":"by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-40e9ffab5f2so10064475e9.1 for <4bd6c97b9@proxiedmail.com>; Fri, 19 Jan 2024 18:00:38 -0800 (PST)",
      "Subject":"hey mate",
      "X-Received":"Received details",
      "body-html":"<div dir=\"ltr\">hey hey<\/div>\r\n",
      "body-plain":"hey hey\r\n",
      "from":"Alex Alex <sender@gmail.com>",
      "message-headers":"HEADERS JSON....",
      "stripped-html":"<div dir=\"ltr\">hey hey<\/div>\n",
      "stripped-text":"hey hey",
      "subject":"hey mate",

   "receivedAt":"Sat Jan 20 2024 02:00:46 GMT+0000",
      "token":"Bearer ...."


Summarizing our information you can use both ways to receive emails: via callback and also using browsing emails. The payload contains all of the information about email and attachments.

If you have any questions please contact devphp@pxdmail.com. Feel free to check out the documentation as well.

Also check out our article about receiving emails on pure PHP:


Let us help you. Explain your problem and we will contact you to solve it.
Email Address
Thank you! We'll contact you soon
Our managers will contact you via email to solve the problem.