PowerMail for Mango Blog

PowerMail is a Mango Blog plugin that improves on the mail utility included with Mango. In particular, it adds BCC support (useful for plugin developers who want to send email with a BCC), and enables you to connect to SMTP servers that require SSL or TLS authentication and/or a custom port number; including GMail and Google Mail for Domains.

This plugin requires CF8+ or Railo 3.1+. More on why later.

If you don't care about the story and just want to download the plugin, you can skip all of this blabbering and go straight to the project page or use auto-install:

Plugin version:
1.0
Last Updated:
2010-01-12
Requires:
Mango Blog 1.3
Auto-install URL:
http://fusiongrokker.com/get/powermail

Why create this plugin?

For a long time I've wanted to be able to use BCC in my Scribe plugin, but Mango doesn't support that out of the box. In addition, I want each of my Mango-powered blogs (all three of them) to be able to connect to a different mail server instead of using the default specified in the CF Administrator -- and although there is a section in Mango's config to specify a custom mail server and authentication for it, there was no way to edit that without mucking around in XML.

And in addition to that... all of my domains are setup to use Google Mail for Domains, and to lower the perceived "spamminess" of mail being sent from my server by the recipient mail servers, I need to funnel that outbound mail through Google instead of using a closed relay service on the web server (thus getting a proper RDNS response); but Mango's mail server settings and the core mail utility don't support TLS or SSL authentication, which is required by Google.

For more information on sending mail from ColdFusion to GMail or Google Mail for Domains, I highly recommend this post by Jamie Krug -- I used this information in building PowerMail. The short version is that if you intend to connect your Mango install to GMail, use smtp.gmail.com, and TLS with port 587 or SSL with port 465. Username is your full email address (@gmail.com optional; but @yourdomain.com required), and password is... you guessed it... your mail account password.

Unfortunately ColdFusion didn't add support for TLS and SSL connection to mail servers until version 8, so CF 7 and earlier are just out of luck. Upgrade, noobs! Railo 3.1 does support TLS/SSL as of version 3.1 (current latest), but I'm not sure how far back that support goes. OpenBD does not currently support TLS/SSL authentication.

What does this mean for Scribe?

I'll be releasing a new version of Scribe tomorrow that takes advantage of this BCC support if PowerMail is installed, but will also continue to work as it does today if BCC isn't available -- so Scribe is still supported where PowerMail isn't: on CF6 and CF7, and OpenBD. This new version also fixes a few recently reported bugs. Those of you with hundreds or thousands of subscribers will be happy to know that this new version of Scribe will also be able to send emails to chunks of 100 subscribers, dramatically lowering the total message count.

This is done because of limitations set by Google on their SMTP service -- You can only send 500 messages per day (if your blog has 5,000 subscribers then you've got bigger problems), and any individual message will be considered spammy and possibly be rejected if there are more than 200 recipients.

Using PowerMail from your own plugins

If you want to use PowerMail's BCC in a plugin you're developing, you can simply require that the user also install PowerMail. You get a copy of the mail utility the same way you would with Mango's default mail utility:

mailer = getManager().getMailer();

You can check to see if BCC is supported by running the supportsBCC function. Since this function doesn't exist in the default mail utility, you need to catch an exception to detect that BCC isn't available (and thus, PowerMail isn't installed), like so:

mailer = getManager().getMailer();
try {
    bcc = mailer.supportsBCC();
} catch (any e) {
    bcc = false;
}

Important Note: PowerMail works by monkey-patching Mango's API when the plugin is started (Mango starts it when Mango is started, or when the blog config is reloaded), and currently there is no way to control the order in which plugins are queued to load. Therefore, you should not create a local instance of the mail utility in your plugin's init function and cache it; and instead you should load a new mail utility at the beginning of an event handler that will be sending email and use that one for the duration of the event. By doing so, you can be sure that PowerMail will have updated Mango's API before you request a mailer, and you will receive the custom mail utility.

Please submit bug reports and enhancement requests through the RIAForge PowerMail Project Page.

in Mango | My projects Posted 2010-01-13 09:30

8 responses:

Mark Aplet
Mark Aplet 2010-01-13 12:31 PM #
Nice plugin Adam. Looking forward to it.
John Sieber
John Sieber 2010-01-13 2:24 PM #
Interesting plugin as well as lots of good information that I did not know about using the google smtp servers.
Brandon Moser
Brandon Moser 2011-02-18 9:36 AM #
Adam,

I have the plugin installed, but can't seem to get the settings to save. I get a "Error while calling plugin com.fusiongrokker.plugins.PowerMail:" error in the Log Viewer. Nothing more. Site is running on Railo 3.2, so all should be well.

You're help would be great. Or at least where I should look for more info.
Thanks,
Brandon
Adam
Adam 2011-02-18 10:02 AM #
Brandon,

I wrote up a guide for debugging Mango plugin issues: http://fusiongrokker.com/post/how-to-debug-mango-plugin-issues

Follow the steps there and let me know how you make out. It sounds like there may be a compatibility problem with this plugin and Railo. If you let me know what it is, I can try to fix it.
Snake
Snake 2011-05-29 5:06 PM #
When saving the powermail settings I just get a blank page and no error and nothing saves.
Nothing in the error log either.

running on CF9.
Snake
Snake 2011-05-29 8:46 PM #
I added some custom error trapping and discovere dthere is in fact an error which is not being logged.

The method saveSetting was not found in component org.mangoblog.Mango.
at cfsettings2ecfm1074655801.runPage(C:\inetpub\wwwroot\michaels.me.uk\wwwroot\components\plugins\user\PowerMail\settings.cfm:34)

hth
Snake
Snake 2011-05-29 9:05 PM #
seems like mangoblog core code has changed which has broken your plugin, scribe also seems to be broken with latest version of mangoblog as well.

Anyway solution to above problem seems to be

replace this
request.blogManager.saveSetting
with this
variables.preferences.put

No error occurs now and the settings do seem to get saved even after reloading the config.
Adam
Adam 2011-06-24 9:38 AM #
I've just pushed an update to github (not to riaforge yet) that has these changes. Would you mind testing it for me?

Leave a comment:

Leave this field empty: