×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Using CMandrill in CLI

Using CMandrill in CLI 11 years 6 months ago #20584

  • Bob Bloom
  • Bob Bloom's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
Daniel,

I want to take a moment first to complement you on creating CMandrill, and for making it avaiable gratis.

After learning about Mandrill, I finally started using it today. Your component/plugin made it very easy to use Mandrill -- my contact form, for example.

I want to start using Mandrill -- and your wonderful component/plugin -- with my LaSalleMart ecomm extension. See my new Knowledge Base page at southlasalle.atlassian.net/wiki/display/...your+email+send-outs .

My first use case with Mandrill is with Joomla's CLI. At the end of all the processing, I want to send an email.

I am successful sending the email with:
$mailer = JFactory::getMailer();
$mailer->setSender($from);
$mailer->addRecipient($to);
$mailer->setSubject($subject);
$mailer->setBody($subject);
$mailer->send();

Getting my CLI app to harness your wonderful component/plugin -- well, I'm having trouble. I am hoping you can help.

I'm doing variations of the following:
JPluginHelper::importPlugin('Mandrill');
JDispatcher::getInstance()->trigger('onAfterInitialise');
$mailer = JFactory::getMailer();
$mailer->setSender($from);
$mailer->addRecipient($to);
$mailer->setSubject($subject);
$mailer->setBody($subject);
$mailer->send();

Do I need to use "jimport('joomla.application.component.helper');" before "JDispatcher"?

Thank you for your help, Daniel.
-Bob Bloom

Using CMandrill in CLI 11 years 6 months ago #20588

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Online
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Do you get any error in the console?
I haven't tried it myself, but your code looks fine...

Actually the plugin will look for the component's config (it needs the api key) and I'm not sure how this will work in a CLI environment.
You'll most probably have to make some die() in the plugin to see if it is at all being triggered.

Using CMandrill in CLI 11 years 6 months ago #20597

  • Bob Bloom
  • Bob Bloom's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
Daniel,

Thank you for your quick reply.

The plugin accesses the component's params to grab the key. So the CLI has to be aware of the component, so that your plugin can then grab it. Methinks!

I have failed in my mission getting your component and its plugin to work in my CLI. My CLI will have to work with the Mandrill API directly.

I succeeded having JMail's SMTP work with Mandrill, but the real power of Mandrill is its API. So I played with different variations of the PHP "wrappers" out there. Most of my variations failed, but some worked. When it worked, I really began to see the potential. Sometimes, do not underestimate the power of "Hello World"!

After all this fun, I'm mulling creating a library for Mandrill, so I can pretend that it's part of the native Joomla Platform. Instead of worrying about components and plugins, I can import CJMail from /library/cjmail akin to /library/joomla -- that's the theory! Then, I'll be able to call it in the same way in LaSalleMart. We'll see, but I'm probably not done with the "Hello World" experiments! I will keep you posted. Your component/plugin has inspired me!

-Bob

Using CMandrill in CLI 11 years 6 months ago #20677

  • Bob Bloom
  • Bob Bloom's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
Daniel,

I published my Mandrill Library for Joomla -- for LaSalleMart! I have a specific use for Mandrill, so it's not quite a generic "standalone" creation. Hence, I won't be seeking JED listing for it.

With appreciation, I have attributed lib_mandrill to you in multiple places.

My blog post: blog.southlasallecommerce.com/2013/new-m...rary-for-lasallemart

My Knowledge Base page: southlasalle.atlassian.net/wiki/pages/vi...ction?pageId=2457667

Free download -- see CREDITS.php: www.lasallemart.com/index.php/component/...pository/libmandrill


I must stress that my Mandrill Library is *NOT* a substitute for your excellent extension. In fact, I anticipate using both your extension and my library on the same site. Why? Because your extension will route new user notifications and any existing JMail sent email to Mandrill. My library will NOT similarly route. That's because you use a plugin event to "intercept" emails. My library has no such "interception" abilities.

Again, thank you Daniel!

Using CMandrill in CLI 11 years 6 months ago #20680

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Online
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey Bob,
Thanks for the kind words and credit :blush:

You actually brought me to an idea. I actually don't understand why I didn't came to it earlier.

You are actually right - the Mandrill class should be a library. The plugin should do the "override" class stuff and it will use the library.

But having the class as a library will ensure that developers will be able to use the API if they need it.

Bob, get ready to be forked! :D:D:D

Cheers,
Daniel

Using CMandrill in CLI 11 years 6 months ago #20691

  • Bob Bloom
  • Bob Bloom's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
Daniel,

That does not sound entirely complimentary! I like the idea of saying "spoon" instead, although "Bob, be prepared to be spooned!" is not necessarily an improvement.

I am glad to have inspired.

Mainly, you'll be forking your own code! The one value-add I offer is my lib_mandrill works in my test CLI app.

Would you consider doing your "spoon" on GitHub.com? Then we can work on this together. Looking forward to it,
-Bob

Using CMandrill in CLI 11 years 6 months ago #20692

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Online
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Yes, of course. CMandrill is already in a public repo on github:
github.com/compojoom/cmandrill

But it won't be any time soon I start on this... too much other stuff

Using CMandrill in CLI 11 years 2 weeks ago #23373

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Online
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey Bob,
Check the new CMandrill. It comes with the Cmandrill library: github.com/compojoom/lib_cmandrill - you could use it in your CLI scripts.

Cheers,
Daniel

Using CMandrill in CLI 11 years 2 weeks ago #23401

  • Bob Bloom
  • Bob Bloom's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
Daniel,

Thank you for letting me know about your update. Much appreciated!

I am leaning towards including your library with my Joomla distribution -- I just started on it with Joomla 3.2.0, calling it LaSalleCMS ( LaSalleCMS.com ).

Thank you for your further work on a Joomla-Mandrill integration. It is important work!

-Bob
  • Page:
  • 1
Time to create page: 0.132 seconds