All Path Messaging
by Souptik Datta on WordPress.org

WordPress Options (Email)
Check out the Github Repository ♥
Limitless Communication: All-in-one, super scalable, messaging Solution for WordPress.
Ok hold on! ✋. So, many words in one line.
Let’s understand each one-by-one.
- All-in-one: What do you want? – Email, SMS, push-notification? Get all-in-one.
- But I don’t want to use 
xyzprovider for SMS, I want to usepqr, can I have that? Yes it provides you with lot of pre implemented providers for all email, sms and push-notification. 
 - But I don’t want to use 
 - Super Scalable: But I want to use an email provider named 
yxryou haven’t heard the name of. Now what? 🧐- No worries! Are you a developer? If yes, just write your own plugin and implement your own adapter and see it nicely hooked-up with “WordPress messaging”. Please refer to this section for implementing adapters.
 
 
And that’s how it provides Limitless communication! 🚀
Quick Links
Setup ⚙️ | Issues | Services and functions 🧩 | Create your own Adapter 🛠️
Coming soon ⏳
- Push notifications
 - Email Testing page
 - SMS Testing page
 - Push notifications Testing page
 
Examples
Email 📧📨
Send an email through a particular adapter (with headers 😉) –
\Souptik\AllPathMessaging\Email\send(
  [ 'dev2@souptik.dev' ],
  'Yay its working!',
  'This is some long mail body.',
  'Souptik',
  'dev1@souptik.dev',
  [
   'cc' => [
    [
     'name'  => 'CC Test',
     'email' => 'cc@souptik.dev',
    ],
   ],
   'attachments' => [
    trailingslashit( WP_CONTENT_DIR ) . '/mu-plugins/test-all-path-messaging.php',
     'SameFileDifferentName.php' => trailingslashit( WP_CONTENT_DIR ) . '/mu-plugins/test-all-path-messaging.php',
   ],
  ],
  'mailgun'
 );
Just remove the last parameter! And now it uses the default selected adapter –
\Souptik\AllPathMessaging\Email\send(
  [ 'dev2@souptik.dev' ],
  'Yay its working!',
  'This is some long mail body.',
  'Souptik',
  'dev1@souptik.dev',
  [
   'cc' => [
    [
     'name'  => 'CC Test',
     'email' => 'cc@souptik.dev',
    ],
   ],
   'attachments' => [
    trailingslashit( WP_CONTENT_DIR ) . '/mu-plugins/test-all-path-messaging.php',
     'SameFileDifferentName.php' => trailingslashit( WP_CONTENT_DIR ) . '/mu-plugins/test-all-path-messaging.php',
   ],
  ],
 );
Checked the override wp_mail checkbox? Try a simple wp_mail! –
wp_mail(
  [ 'dev2@souptik.dev' ],
  'Yay its working!',
  'This is some long mail body - from wp_mail.',
  [],
  []
 );
SMS 📲
Send a SMS through a particular adapter –
\Souptik\AllPathMessaging\SMS\send( [ '+xxxxxxxxxxxx' ], 'Yay its working!', 'twilio' );
Just remove the last parameter! And now it uses the default selected adapter –
\Souptik\AllPathMessaging\SMS\send( [ '+xxxxxxxxxxxx' ], 'Yay its working!' );
Creating your own adapter 🛠️
Here comes the cool part fellow developers! 💻
Tip: I have provided a dummy adapter for each service at inc/.
Consider that as the starting point and let’s understand what each file does.
- Let’s start with 
namespace.php. It is the entry point of your adapter.- In that you will see a simple 
bootstrapfunction. - In that function we are hooking into 
EMAIL_SLUG . '_adapters'and registering our adapter. - We pass the following data –
 slugnameadapterclass object.options– An array defining the settings required for this adapter, which will be used to automatically display the options on the settings page.
 - In that you will see a simple 
 - Next is 
class-adapter.php, which is the Adapter class, which we initialized in the above file and passed it toadapter. It contains three simple functions –get_settings_fields– This is the function which returns the array of options, which we used in the above file foroptions. Each option, will have –- The key as the name of the option.
 - And three values –
label– Label to display in the settings page beside the input.type– Type of the field.sanitize_callback
 get_settings– This function returns an associative array, whose keys are the name of the options and the value as the value of the options.get_adapter– This function will just return the core provider class, which is responsible for processing the message.- First check if 
Utopia Messagingalready provides the provider or not here, for exampleUtopia\Messaging\Adapter\Email\Mailgun. - If it is present just use it. Easy peasy! ✨
 - But if not, let’s code it ourself, because 
Utopia Messagingmakes it so easy to create a new adapter! 
 class-dummy.phpis for that purpose, assuming you don’t get a provider already present inUtopia Messaging.- It’s basically a child class of 
EmailAdapterorSMSAdapter, which abstract a lot of stuff for us! - Let me explain two main functions, 
_constructandprocess. Rest of the functions and properties are self-explanatory! 😉 - In the 
_constructfunction just put the arguments which you want to accept. That’s it! And now they will be available everywhere else as$this->param_name! - The 
processfunction is the place where you have to write the main logic of calling your providers API to send the message.- As said above all the credentials/data you accepted through constructor are available as 
$this->param_name. - Build the 
bodyand theheaders. - And then you can use the 
$this->requestfunction as demonstrated in the dummy! - Create a response using Utopia’s 
Responseclass. - Handle the errors, populate the response, return! Done! 🚀
 
 - As said above all the credentials/data you accepted through constructor are available as 
 
- It’s basically a child class of 
 
External services
Brevo
This plugin connect’s to Brevo’s API to send emails through Brevo. This is the API it sends the request to.
The request is send everytime a mail is sent, and Brevo is selected as the default adapter from the plugin settings (or the function to send email through Brevo is directly invoked in the code).
Here is the Terms of Use and Privacy Policy of the service.
AWS SES
This plugin connect’s to AWS SES’s API to send emails through AWS SES.
The request is send everytime a mail is sent, and AWS SES is selected as the default adapter from the plugin settings (or the function to send email through AWS SES is directly invoked in the code).
Here is the Terms of Use and Privacy Policy of the service.
Mailgun
This plugin connect’s to Mailgun’s API to send emails through Mailgun.
The request is send everytime a mail is sent, and Mailgun is selected as the default adapter from the plugin settings (or the function to send email through Mailgun is directly invoked in the code).
Here is the Terms of Use and Privacy Policy of the service.
Telesign
This plugin connect’s to Telesign’s API to send SMS through Telesign.
The request is send everytime the function to send SMS is invoked with the Adapter as Telesign or the default adapter is set as Telesign.
Here is the Terms of Use and Privacy Policy of the service.
Twilio
This plugin connect’s to Twilio’s API to send SMS through Twilio.
The request is send everytime the function to send SMS is invoked with the Adapter as Twilio or the default adapter is set as Twilio.
Here is the Terms of Use and Privacy Policy of the service.