Mandrill support for vBulletin v1.0

by GHDpro is email distribution platform which makes it easy to see if mail is delivered or not. Integration with vBulletin is fairly easy, I've written a plugin and a small PHP file to make it work better.

At this time this mod is fairly simple, it adds one plugin (to the default "vBulletin" product) and a PHP file you will have to edit to make it work.

Both the plugin and the PHP file seem to work fine under both vBulletin 3 and 4 (latest version).

Basic Setup

Using Mandrill is fairly easy, sign up for an account, create an Mandrill API key (in Settings) and enter the required information in vBulletin Options in the "Email Options" section. "SMTP Secure Connection" should be set to TLS.

For security you might want to configure the Mandrill API key to only work from your forum server's IP address and only allow SMTP and nothing else.

To find out the IP for your forum server, send a test mail (from the vBulletin Admin CP: Maintenance -> Diagnostics, second option) and then check the "API logs" in Mandrill (in Settings).

To only allow SMTP, edit the API key and tick "Only allow this key to use certain API calls" and then tick only the Send-raw option out of the list.

Contact Us problem

There is a problem with vBulletin where it will send messages using the "Contact Us" forum on behalf of the user. This will pollute your Mandrill account:

Sending Domains Senders List

To avoid this problem, the included product-mandrill.xml file contains a plugin that will rewrite the "From:" field in emails send by vBulletin to always be your webmaster's email address (as you set in vBulletin Options).

If you use Mandrill sub-accounts, you can also set the sub-account name by editing the plugin.


The webhook is probably the best demonstration how Mandrill can be useful. It completely automates handling of bounced mail.

What the webhook does is, if Mandrill detects a bounce/rejected mail, it will post information to the webhook PHP script. The script will then look up the email address supplied by Mandrill in the vBulletin user list and move the account to the "Users Awaiting Email Confirmation" group (usergroupid: 3). To avoid admins/mods getting moved (and demoted) it will only do this for users in the "Registered Users" group (usergroupid: 2).

You add the webhook in Mandrill (in Settings -> Webhooks) by specifying the complete URL to the file and enable the "Message is Bounced / Marked as Spam / Rejected" (3x) event triggers.

Then edit the PHP file (be sure to upload it again after you are done) and set the exact webhook URL and key into the variables at the top. Make sure there are no extra spaces or it will not work.

If you want to see if it is working also set the $webhook_logfile variable to a file that must be writable by the webserver (by setting the right file and/or directory permissions).

What you can then do is add a notice in the Notice manager to display a warning to those in the "Users Awaiting Email Confirmation" group to update their email address:

<span style="color:red;font-weight:bolder;">Hello {username}, your forum account needs to be activated.</span>
<p style="margin-top: 0.5em">
You will not be able to post or upload a custom avatar until you activate your account. To activate your account, follow the instructions in the activation email.<br /><br />
If you've just joined the forum, the email has already been sent and you should receive it shortly. If you have not received it, you can <a href="register.php?do=requestemail">request it again</a>.<br /><br />
If you have been registered for a while your email address might be incorrect. If we detect too many emails to your email address bouncing (meaning it comes back to us with an error) we will mark your account for reactivation. You should check the <a href="profile.php?do=editpassword">email address set in your profile</a>.<br /><br />
<b>Note:</b> Some email providers incorrectly mark activation emails as spam. Make sure you check your spam/junk folder before contacting us for assistance.</p>