Skip to content

Services and functions 🧩

Souptik Datta edited this page Oct 11, 2024 · 1 revision

Email 📧📨

Send an email through a particular adapter (with headers 😉) -

\Souptik\WPMessaging\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-wp-messaging.php',
     'SameFileDifferentName.php' => trailingslashit( WP_CONTENT_DIR ) . '/mu-plugins/test-wp-messaging.php',
   ],
  ],
  'mailgun'
 );

Just remove the last parameter! And now it uses the default selected adapter -

\Souptik\WPMessaging\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-wp-messaging.php',
     'SameFileDifferentName.php' => trailingslashit( WP_CONTENT_DIR ) . '/mu-plugins/test-wp-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 <strong>wp_mail</strong>.',
  [],
  []
 );
Keep using your favorite email marketing/managing tool ❤️

The interesting part of this plugin is that it only focuses on solving the smallest purpose it is created for in the most efficient way possible.

For almost all the email marketing/managing tool there is an option to select how you want to send the email (if there is none, then it by default uses wp_mail), like these -

default-mail-method-example-1 default-mail-method-example-2

If you are using any other mailer/method in these plugins, just change to this default option and see how seamlessly wp-messaging hooks in and sends emails reliably through your selected adapter! 😎

SMS 📲

Send a SMS through a particular adapter -

\Souptik\WPMessaging\SMS\send( [ '+xxxxxxxxxxxx' ], 'Yay its working!', 'twilio' );

Just remove the last parameter! And now it uses the default selected adapter -

\Souptik\WPMessaging\SMS\send( [ '+xxxxxxxxxxxx' ], 'Yay its working!' );

Push notification 💬

Coming soon! ⏳