bbPress Notify (No-Spam) Reply by Email Documentation

bbPress Notify (No-Spam) Reply by Email Documentation

bbpnns Reply By Email (RBE for short) is a powerful plugin. It gives your forum participants the ability to reply to new forum posts without having to log into your site. They can even dictate their emails on their phones, so no typing is required.

However, getting it set up initially can be a little tricky if you don’t understand the concept behind it. Keep reading if that felt close to home.

Getting Started

RBE is an extension of bbpnns. It relies on bbpnns to send the notifications to your users. When it sees a notification going out, it will change the reply-to email header of that outgoing message so that any replies go to a mailbox it has access to.

From time to time (more on that later) it will check that mailbox, parse the headers and body of each message and create the reply under the correct topic. It even respects nested replies!

By the end of this article you’ll:

  1. Know what a Plus Alias (or Dynamic Alias) is;
  2. Have a better understanding of what a Cron job and Webhook are;
  3. Have all you need to easily set up your Reply By Email add-on.
So let’s get to it!

    The Mailbox

    As you just read, RBE needs to have access to all of the email replies so it can do its thing. To do its thing, it needs to know a few pieces of information: who’s the user posting, and what’s the forum, topic, and parent reply (if any) it should take into consideration when posting the body of the message.

    There aren’t many reliable ways for it to do that without putting a huge performance hit on the WordPress database. Enter Plus Aliases (aka Dynamic Aliases).

    Plus Aliases (we’ll stick with that name for convenience) are a handy feature that Gmail and a few other email providers came up with. It allows one mailbox to act as pretty much infinite mailboxes. How? By using a simple character, the + sign, to identify the actual mailbox (before it) and any combination of characters (except @) after it and send all messages to the actual mailbox.

    So let’s take the email address [email protected] as an example. There are 2 parts to it: foo, the account, and foobar.com the server. What Plus Alias support does is let you send a message to something like [email protected] and still get the message as if it was sent to [email protected]

    That’s really handy! Common applications for this are: reduce the number of mailboxes you need when applied in conjunction with mail rules; know which site is selling your email to spammers by using a special alias for each site you give your email to; and allow Reply By Email to know the meta data required to post a message.

    So how do I get my hands on a Plus Alias, you ask?

    So far there are 2 large email providers that support Plus Aliases: Gmail and Hotmail/Outlook. Oddly enough, Outlook 365 does not support them – not easily at least. The good news is that those that do are free.

    You’ll find the Mailbox connection settings under

    Admin > Settings > bbPress Notify (No-Spam) – Reply by Email Settings > General tab

    Using Gmail/G Suite

    Gmail and G Suite (formerly Google Apps) are the most popular Plus Alias providers out there. Heck, they may have been the original inventors of Plus Aliases.

    RBE comes with pre-defined settings to connect to Gmail (and G Suite, but we’ll just say Gmail for brevity). All you need to do is paste the full email address in the username input field, the password in the password field and Bob’s your uncle. Well, most of the time. Gmail can get a bit picky with who accesses their mailboxes.

    First, we recommend that you get a dedicated mailbox for RBE to use. If you choose to use your own or one that has, say 7GB of old messages going back 10 years, RBE will probably have a hard time finding the ones that it really cares about.

    Second, you really need to test the connection after entering the Gmail credentials. If it fails you should log into the mailbox and look for security emails coming from Google.

    You may have to do one or both of the following:

    Follow the links above for information on how to enable them. Usually just enabling Less Secure Apps works fine. Click the Test Connection button after each one to see if it works. Don’t be discouraged with the ‘Less Secure’ terminology. RBE communicates with all mail servers via secure SSL connections.

    WARNING: There’s one caveat regarding the Gmail account to use. If you’re using a gmail account in your Admin > Settings > General >  Email Address, then you cannot use the same account for RBE. That’s because bbpnns uses that email address in the From field, and Gmail will see that the From and To fields are the same and ignore the Reply-to header containing the meta data that RBE needs. It’s a Gmail thing and we can’t do anything about it. Sorry.

    Once it’s all set up, click Test Connection again and it should work just fine. Remember to save!

    Using Outlook/Hotmail

    Hotmail was my very first public email address. That’s when Geocities still existed and IE 3 would come in a set of 3 or more floppy disks (now known as the save icon). A few decades later Microsoft buys it and makes it part of the Outlook family.

    The good part is that it also supports Plus Aliases, and even better, it doesn’t seem to complain about less secure apps or application passwords. Just paste the full email address in the username field, the password in the password field, and click Test Connection. Remember to Save!

    From Email to Forums

    Now that you’ve got your mailbox set up, it’s time to take RBE for a spin. The first thing you’ll need to do is to make sure bbpnns is working properly. Without it, RBE cannot set the headers that it needs to do its thing.

    Setting up bbpnns is pretty trivial, if you’re working on a brand new wordpress install without any real users. Things get tricky if you have real users and don’t want to spam them with test notifications. We strongly recommend setting up a staging site to test out the settings, or you’ll run the risk of having some very angry users.

    If you must test on a live site (please don’t!), then at least temporarily set the notification role to Administrator (or some custom role created just for testing) and disable Override Subscriptions to Forums and Override Subscriptions to Topics in the Topics and Replies tabs of bbpnns, respectively. Don’t forget to turn off background notifications during testing.

    You may find it tedious to create new topics in the front-end for testing. We find it, too! And with that in mind we created the Send Notifications metabox in the Topics and Replies back-end. Just check the box and click Update and the notifications will be triggered.

    Once you get the message out, check your test mailbox (the one that usually receives the notifications, not the one you set up for RBE). Once the notification arrives, make sure RBE modified it for its needs. This is what you should look for:

    1. The body of the message contains a paragraph that says
      ##- If you want to reply, type it above this line -##
    2. The reply-to header has been set and is the email account you set up for RBE along with +usc_ and a bunch of characters before the @.

    If you’re seeing that, then things are looking good. If you’re not, feel free to contact support and we’ll take a look.

    Go ahead and reply to that message. The To field should show the special RBE address. If it doesn’t and you’re using Gmail, refer to the warning above. Write anything you want in the message above that special paragraph and send the message. Check the RBE mailbox to see if the message gets there, but don’t open it! RBE looks for unread messages for performance reasons.

    The First Run

    So you now have a message waiting in the RBE mailbox. How do you test if it’s going to work?

    That’s actually quite simple. First make sure your Check Method is set up for Webhook (save the settings!). Then copy the Webhook URL (blurred in the image above) and paste it in a new browser tab/window. You should end up with a message depicting how many emails were processed. If none were processed and you saw the unread message in the RBE mailbox, please contact support. If you had too many unrelated messages in the mailbox, it could be that the script timed out while sifting through the pile looking for the emails to post. That’s why it’s important to have a dedicated mailbox just for RBE.

    Go to the topic where you expect your reply to be and see if it’s there.

    –Sidebar–
    Depending on the email client that you used to send your reply, you may see some spurious text after the reply. That’s because some email clients add weird stuff between the actual message and the special paragraph. We have lots of code working to remove that weird stuff, for most of the common email clients actually, but some more obscure ones may still pose an issue. If that’s happening to you, please contact us so we can adjust the plugin accordingly.
    –/Sidebar–

    Feel free to reply to your reply in the front-end and send another reply to the reply to the reply… (I lost count) via email. Once you’re satisfied with the functionality, it’s time to automate it.

    To Cron or to Webhook

    RBE will let you automate it in several ways. They all involve either Cron Jobs or third-party integration (with IFTTT, Zapier, etc.). You can even use the WordPress Cron by itself if you want, but we don’t recommend that unless you have LOTS of traffic.

    You can follow this link to read up on how to set up this section, but the simplest thing is to use a Real Cron job along with the Webhook URL. Most hosts offer some sort of real cron job interface (such as cPanel). Siteground (my favorite host so far) has a good tutorial on how to set up real cron jobs in cPanel for WordPress. The steps for the webhook are pretty much the same, but the actual command that’s run is different. It’s a good idea to follow the steps outlined in that tutorial to replace the WordPress internal Cron job (just follow the steps to the letter), and then follow them again (skipping the DISABLE_WP_CRON part, which is done only once) and using the following command instead of the original one:

    wget -q -O - https://yourdomain.com/?bbpnnsrbe-run=thesecretkey >/dev/null 2>&1

    Replace https://yourdomain.com/?bbpnnsrbe-run=thesecretkey in the command with your Webhook URL.

    Make sure that you still have Webhook set as Check Method or you’ll get an HTTP 400 error when the cron job runs.

    Only use the WordPress Cron method if you’re NOT going to use the Webhook URL anywhere and will depend on WordPress to try to respect the check frequency.

    Other Settings

    If you managed to get this far unscathed, the rest is smooth sailing. The remaining settings in this section and in the Message Processing section are pretty much self explanatory. If you choose not to delete read messages, RBE will try to move them to a special folder in your mailbox (if you’re using IMAP which is the default for Gmail and Outlook) so as to be able to process newer messages faster.

    The options in the Message Processing section are mostly site owner preferences to limit what can or cannot be posted into the forums.

    Subscription Integration Settings

    This part helps RBE notify everyone who needs to be notified when a reply to a new topic is posted.The section fully explains what each option does. We recommend setting this to Use bbpnns Rules, if you’re happy with your bbpnns setup and don’t have any membership plugins installed.

    How to move a WordPress site in 10 minutes or less

    WordPress Hosting

    I’ve had a VPS server at Rimuhosting.com for years to host UseStrict Consulting and other websites. I really enjoyed having root access and all the liberties that come with it. It was going really smoothly until I decided to try out Bitnami instead of the native PHP + Apache installs on my Ubuntu server – “if it ain’t broke…”, right?

    But I did touch it and it did break. It turns out Bitnami has some php-fpm memory leaks that I couldn’t get around, and I figured I’d had enough of having to do sysadmin work for the time being. I decided I’d move to a managed hosting company where they’d take care of those issues for me. After some digging, I heard great things about SiteGround (yes, it’s an affiliate link – I like it so much that I endorse it) and decided to try it out.

    After moving a few of my sites, I thought I’d share my experience on how to move a wordpress site. Yes, the title says it’s done in 10 minutes or less – I have it down to less than 5, honestly. It depends on how much practice you have, so your mileage may vary. 🙂

    The rest of this article will assume that your new host give you access to cPanel and simple one-click WordPress installs. Let me know in the comments if you want the non-cPanel version and I’ll write it up.

    Ingredients

    Here are the ingredients you’ll need for a quick and easy move:

    1. SSH or SFTP Access to both old and new servers;
    2. cPanel access on the new server;
    3. Access to your domain’s DNS settings;
    4. Remember to replace all occurrences of foobar.com below with the domain you’re moving;

    If you’re not familiar with SSH, you’ll be able to do everything using SFTP and other tools like phpMyAdmin, but I find SSH faster. If you’re stuck with a Windows computer, look into getting PuTTY installed. In my days of having to use Windows, I’d also always use Cygwin.

    Move a WordPress Site

    The first thing you need to do is make sure your new host is ready to receive your domain. Go to your cPanel Home and set up the domain you want to move. If it’s your account’s primary domain, that’s already done. If it’s a secondary domain, create it as an Addon Domain. Let’s assume it’s an addon domain.

    Creating an Addon Domain

    Click on the Addon Domain icon in the domains section of cPanel. You’ll be taken to a page with a form to set up the new domain.

    cPanel Addon Domains Icon

    cPanel Addon Domains Icon

    Fill in the form with your new domain. The rest (except for the password fields) will automatically be filled in for you. Feel free to change the default values, but for the purpose of this tutorial, we won’t change anything.

    Create an AddOn Domain

    Create an AddOn Domain

    Click ‘Add Domain’ and this part is done. Next, we set up WordPress on the new domain.

    Setting up WordPress

    Back in your cPanel home, look for and click on the WordPress autoinstaller. Yes, you can choose to install WP yourself, but then you probably wouldn’t need these steps at all. But I digress…

    cPanel Autoinstallers

    cPanel Autoinstallers

    SiteGround uses Softaculous to install applications. Granted, I don’t have much experience with cPanel (I’ve always done stuff manually) so I don’t know if it’s something every host uses or not. When you click on the WordPress autoinstaller, you’re taken to the Overview screen in the installer page. I’ve done this a few times now, and for some reason I’m wired to look for an install button at the bottom of the page. It’s not there. Look for the blue install button right next to the Overview tab.

    WordPress Install Button

    WordPress Install Button

    Once you click on the ‘Install’ button, you’re presented with some basic fields to fill in. As you’re moving your site from your old host here, you really care about the following only:

    • Protocol (whether it’s HTTP or HTTPS)
    • Domain (select the AddOn domain that you just created)
    • Directory (leave empty to install WordPress under /home/youraccount/www/foobar.com)
    • Table Prefix (THIS MUST BE THE SAME AS YOUR EXISTING WP INSTALL)
    • Language (select the language of your existing WP install)

    Now, you’ll have to live with the fact that the database name and credentials will be different, so if you have any third-party connections to your existing WordPress install, make sure to change them later.

    Click ‘Install’ and wait until the progress bar finishes. You’re now ready to receive your old WordPress.

    Export Your Old WordPress

    The main thing here is that you want to export a dump of your old WordPress database. I use the terminal via SSH whenever I can. If you don’t like to use a terminal and SSH, export it via phpMyAdmin.

    This is what I’d typically do via the terminal (on the old server):

    $ mysqldump -u <username> -p  <database> | gzip -c > old-wp-dump.sql.gz
    

    Adding the password to the command line isn’t safe, so we leave it out and get prompted for it after we hit enter. Note that we’re also compressing on-the-fly.

    Once you’re done with the database, make sure to create a tarball of your old wp-content directory as well.

    $ cd /path/to/wordpress/install
    $ tar -czvf old-wp-content.tar.gz wp-content/
    

    Download both files to your computer (or leave them temporarily in a place where you can access them via a browser on your old server).

    Import Into the New Server

    Now we need to get those two files into the new server. I’m still using SSH, but you can use SFTP if you want to.

    First thing to do is to back up your new server’s automatically-created wp-content directory (or rename it using SFTP):

    $ mv /path/to/www/foobar.com/wp-content /path/to/www/foobar.com/wp-content.orig
    

    Back up the automatically-created database. You can find the credentials in your new wp-config.php file.

    $ mysqldump -u <new-username> -p <new-database> | gzip -c > new-wp-backup.dump.sql.gz
    

    Now move the old server’s files to your new server. If you chose to leave them in a place accessible via a browser, you can use wget (if it’s available in your new host – it is on SiteGround) to download them directly to your server. Otherwise use SCP or SFTP to upload them from your computer.

    We’ll need to uncompress the files soon. Unfortunately, SiteGround doesn’t have gunzip, but you can get around that with gzip -d (and even create an alias for it in your ~/.bashrc file – alias gunzip="gzip -d ")

    It’s time to do the actual move. The following commands will read the compressed information and handle them accordingly. To import the database, use mysql:

    $ gunzip -c old-wp-dump.sql.gz | mysql -u <new-username> -p <new-database>
    

    Again you’ll be prompted for the password after hitting enter. All of the old tables will be created, replacing the new ones as long as you used the correct table prefix when you ran the autoinstaller.

    Now uncompress your old wp-content:

    $ mv old-wp-content.tar.gz /path/to/www/foobar.com/
    $ gunzip -c old-wp-content.tar.gz | tar -xf -
    

    Replace the Auth Keys and Salts

    WordPress uses several Authentication Keys and Salts. In order to avoid issues logging into your new server’s install, you’ll have to replace the salts in the new wp-config.php with the ones from your old one.

    The entry in wp-config.php typically looks like this:

    /**#@+
     * Authentication Unique Keys and Salts.
     *
     * Change these to different unique phrases!
     * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
     * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
     *
     * @since 2.6.0
     */
    define('AUTH_KEY',         ';LM|C1Op{p`aE>6 FTO64{n#J2c,5KDK6:UxO.OGjHp[`<d%Wj<Fxid-Y_3}#rIn');
    define('SECURE_AUTH_KEY',  '6b*K_`ie.A7b2):A-0&|arFv]+b04hT2g93TTRUJHBfp>DL=vJ-a}A9Rh:[email protected]');
    define('LOGGED_IN_KEY',    'Q8853bl6ZP-F>r(>wpJhbQu>M|Jt{b6zCcUwR3oyA/6+y<~l#-~,JA-WE.L{[email protected]');
    define('NONCE_KEY',        'GzVYsIDpbKi%4,xVODWZRE3w?}[email protected]>I=cM VF[u6AuQF20Cta)Hr9s<hh');
    define('AUTH_SALT',        'FmSUv`pq2|%K}yb~r*e)+(,G1}:7I7;/TBxg>h_Ejm0HDD:Y^G&x,yf9t9IRD$3p');
    define('SECURE_AUTH_SALT', 'C,QO;+Iu0xw&U}x7}+O_2PS#wn:&z?zh5:75Ys}b[[email protected]|;dgR+R<u8%[B');
    define('LOGGED_IN_SALT',   'T_[R}qRiDS2Ye2z|V:A8?ogn,nU[}[+!wcD#W!X.2)ZC8n5*)sC*Y%Ks*&vo++eT');
    define('NONCE_SALT',       '[lP_CFP70&i6l- )z(6Cw <o<0ZDG?sxJ&o&.t|m!xkX!z3$QLB.[dG9XRHE^ yd');
    

    Test It

    Your migration is now ready for testing. Pull up your new server’s IP address from your cPanel home and add it to your /etc/hosts file (C:\Windows\System32\Drivers\etc\hosts in Windows)

    123.123.123.123 foobar.com

    Save the file and test your website. You should not see any difference at all when viewing it or logging in.

    Once you’re satisfied, change the DNS A entry to point from the old IP to the new IP and that’s it! You’ve moved your website successfully. Allow for a couple of days of DNS propagation before taking your old one down.

    As an added bonus, if you’re dealing with a high-traffic site that gets lots of database changes, you can set up Remote MySQL connections in cPanel, whitelisting your old server’s IP for incomming connections, and then change your old server’s wp-config.php to connect to your new server’s MySQL database. That way changes coming from people who still have a cached DNS entry pointing to the old server will be made on the new database automatically.

    Important Changes to USC Plugin Sales and Support

    When I started selling WordPress plugins at UseStrict Consulting, I planned to provide life-time updates and free support for all. As it turns out, there are a few fundamental flaws with this business model:

    1. There’s no control over unauthorized copies;
    2. Providing free support takes time away from coding new and exciting things;
    3. There is no business growth;

    Over the following weeks, I will be implementing a plugin licensing system, and support will be provided to subscribers only. I believe this will be a win-win situation, as I will be able to provide (even) faster support and better plugins.

    I’m still studying how to handle old clients, and will post updates as soon as I have more information.

    Cheers,
    Vinny

    eShop Fixed Discounts – Free plugin

    So here it is, what many have asked for. You can now offer fixed-rate site-wide discounts for eShop instead of just percentage. You can download it for free at WordPress.org.

    eShop Fixed Discounts Admin

    Modified Discounts Admin form

    eShop Cart with fixed-rate discounts

    Cart calculating/showing fixed-rate discounts

    If you’d like to also offer fixed-rated discount codes/coupons, please consider purchasing eShop Coupons Plus, which is a substitution for eShop Fixed Discounts.

    Cronblocks for WordPress

    A couple of years ago I had an idea of a project targeting people who want to offer dynamic content on their sites but do not have the programming knowledge to do so. I called it Cronblocks (http://cronblocks.com) – a system where the user can create snippets of content and choose when to display them. Not satisfied, I decided to add Geo-Location as a possible condition for displaying the snippets. It worked (and still works) fine for sites built in plain html or any programming language as the code is sourced via Javascript.

    I recently decided to write a port of Cronblocks as a WordPress plugin as a proof of concept, with the following features:

    1. Snippets are a WordPress Custom Post Type
    2. They can (and should) be grouped into category-like taxonomies called Snippet Groups
    3. Set the snippet controls to use either Geo-Location (visitor’s country) or a Scheduled display time range and date (choose days of the week or days of months)
    4. Assign the Snippets to a Snippet Group (just like categories)
    5. Control overlapping Snippets in a Group with Priorities

    To use it, place the Snippet Group shortcode to control where on your page/post you want the appropriate Snippet to be displayed, and that’s it!

    The plugin will check for all snippets associated with the shortcode’s Snippet Group and will decide which one should be displayed according to the control settings for each Snippet. If more than one Snippet match the display conditions, a random one of the matching set will be selected.

    As mentioned above, this is a proof of concept. I plan on writing a fully featured companion plugin that will offer the following:

    • Enable multiple control conditions of each type, and mix/match
    • Keep and show statistics of snippets being displayed
    • Optionally display snippets based on the visitor’s local time
    • Optionally reload the snippet group after a given amount of time (say a visitor is watching a video, reload the snippet group after 3 minutes)
    • Enable Region and City scope
    • Use Maxmind GeoIP2 database, which is more accurate than the GeoIP databased used in the Cronblocks plugin
    • Allow overriding of snippet options via the shortcode attributes
    • Set up roles that can access the snippet administration
    • Add an icon to the TinyMCE interface as a shortcut to inserting the shortcode
    • Add a Snippet Group Widget

    While the fully featured one doesn’t come out, feel free to download the proof of concept from WordPress.org’s plugin repository: Download

     

    Didn’t find what you came for?

    The cool thing about blogging software is that it shows the blogger all sorts of interesting information, such as the number of visitors, or the search string that led them to the blog.

    I see lots of interesting search strings, but I keep wondering if the users actually found what they were looking for. That said, please be kind and leave a message telling me if you found what you wanted, and if you didn’t, please say what it was and I’ll try to cover that in my posts.

    You can leave your message either as a comment here, or send me an email through the contact form.

    Thanks!!

    New looks for usestrict

    Folks,

    I decided to change the looks of my blog. I’m using Atahualpa theme which is simply amazing. There are over 200 customization options which allow you to do practically anything you want.

    If you are wondering about the logo, it is one of Pablo Picasso’s drawings. I chose it because of its simplicity, which is in my opinion one of Perl’s faces (I try not to get on its bad side – K.I.S.S.).

    I hope you enjoy it.

    Vinny.

    DBD::Oracle + Cygwin: Undefined reference error during make

    Yesterday I found myself in a position of having to re-master my computer – hence having to reinstall most of the applications including my trusty Cygwin – which always becomes somewhat of a headache when I reach the point of installing DBD::Oracle in it.

    This time I got a undefined symbol error. A quick look in Google showed me that Erik Squires had the same exact problem. Lots of searching later, I find that Google can’t find a handy solution anywhere… So I send Erik an email asking about the solution and to my surprise, he answers only 1 (!!) minute after I click send. Talk about a fast reply!!

    Hats off to Erik! You will find the solution here: http://cpae.typepad.com/capacity_planning_and_eng/

    Hint: the oci.def that he mentions in his post is inside your DBD::Oracle build directory. Don’t get it confused with ocidef.h file in your $ORACLE_HOME/oci/include directory (that’s where I looked first).

    I’m adding the error message below with a big SOLUTION header for any Googler out there having the same problem. No need to keep reading if the text above was enough to solve your problem.

    Continue Reading…

    Future postings on MySQL

    On my previous post, I talked about MySQL functionality “insert into … on duplicate key update” which I found really cool. It has since been the most popular of my messages (although nobody leaves any comments), so I guess I’ll start talking more about MySQL… Don’t forget to keep an eye out for fresh Perl updates as well though – the Perl Crash Course is slowly coming out of the oven.

    Cheers to all.
    Vinny

    print “Hello world!n”;

    Welcome to Vinny’s Technical Corner. Here you’ll find some (hopefully) interesting posts regarding the *nix world, general programming techniques, Perl, and other languages – web oriented and not.

    I’ll try to keep the posts neatly organized in categories, for programming newbies to rocket scientists – in case there’s one out there who would like to share a piece of his/her mind with us…

    So, welcome to my blog!