Using Gmail SMTP Servers to Send Email From WordPress on DigitalOcean

Use Gmail SMTP Servers for Sending Emails from WordPress

After quite a bit of back and forth between sendmail, postfix, and exim, I’ve settled on using msmtp for sending emails from my servers/droplets at DigitalOcean (affiliate link).

MSMTP is very lightweight and has the ability to send emails via an existing SMTP server, like Gmail’s or Yahoo’s.

To get it working, there’s a few tricks. I’ve pieced this together from this post and this post. And when on DigitalOcean, there’s an IPv6 issue that causes major delays in sending the email, which there’s a fix for at the end of this post.

1. Install msmtp

2. Configure msmtp to use Gmail

Open up /etc/msmtprc as root: sudo nano /etc/msmtprc, and add the following, removing whatever else is there:

You’ll want to replace the user directive with a valid Gmail email address, a Gmail account or a Google Apps email address will work, too. Don’t forget to change enter-password-here! to the actual password for the Gmail account your using.

Save /etc/msmtprc.

3. Remove Sendmail

Run this:

4. Setup Some Aliases

Lots of software on Linux systems uses the sendmail command. Instead, we’re using msmtp, so we’re essentially invoking msmtp when the sendmail command is run.

5. Tell PHP About msmtp

First, locate your php.ini file that’s being used by Apache. It’s typically in /etc/php5/apache2/php.ini. If that’s not it, use PHP’s phpinfo() function to find the location of your php.ini file.

Find sendmail_path = in php.ini and replace it with this:

Now you should be able to send mail using PHP’s mail() function, which will use the Gmail SMTP server to send emails. Add this to a PHP file and access it through your browser to see if it works:

6. Disable IPv6 If You Experience Slowness

Open up /etc/gai.conf like so:

Now, look for a line that looks like this: #precedence ::ffff:0:0/96 100. Uncomment that line (remove the #) and save /etc/gai.conf. An explanation of why this helps can be found in this comment at the DigitalOcean article.

All Done

That should be it. If you run into any issues please do leave a comment, I’ll do my best to help you out. I may have missed a part, so no guarantees this will work for you. It does however work wonderfully on a DigitalOcean droplet that’s running Ubuntu 14.04 with a pretty standard LAMP stack.

You should now be able to send email from WordPress on DigitalOcean.


Add Markup to WooCommerce Products

WooCommerce & Is Awesome

Adding markup to a well coded WordPress theme is relatively straight forward and doesn’t take very long to get setup.

I covered how to add markup to your WordPress theme in a previous post, but I recently needed to apply markup to an e-commerce site using WooCommerce.

It’s surprisingly easy to do. You’ll need to be using a child theme for the steps that follow.

1. Setup the necessary function in the functions.php file for your theme

Add the following to your functions.php file. It creates a custom function, schema_org_markup.

2. Call schema_org_markup() In Your Header

Open up the header.php file for your child theme and find the html tag, usually towards the top. You’ll want to call the schema_org_markup function inside that html tag, like so:

3. Create a WooCommerce template file in your child theme

Create a directory in your child theme folder named woocommerce. Inside the woocommerce folder, create another new folder named single-product. Inside the single-product folder, create a file named price.php. The contents of your price.php file should look like this:

4. All Done

That’s all that’s required to add markup to individual WooCommerce product pages. Pretty simple.

If you run into any issues or it doesn’t seem to be working for you, let me know. I’ve only tested this with two themes, Vantage and Virtue. Remember, this only works with well-crafted WordPress themes. Doing this with purchased themes from ThemeForest or other paid theme marketplaces can be significantly more difficult.

Comments are open so let me know if you have any issues, additions, questions, or suggestions.

My Portfolio

I finally have one!

I’ve known for a long time that I need some type of portfolio, especially since I’m doing freelance web development full-time now.

A potential client wanted to see my portfolio. I explained that I didn’t have one for various reasons, and instead described to him some of the more interesting projects I’ve done.

After the long email describing previous projects, I decided to create an online portfolio. I had recently bought the domain, but wasn’t using it for anything. So, I found a nice Twitter Bootstrap based portfolio WordPress theme and got to work. The theme needed some tweaking, the grid displaying the projects was a bit messed up and needed fixed, which was very easy.

The theme I chose was StanleyWP, a simple, minimalistic portfolio theme. The best thing about it was it’s price, free.

It’s built with Twitter Bootstrap 3.0.3, which is a little old, but still gets the job done. The current version of Twitter Bootstrap is 3.2.0.

Once I get some client projects finished up, I’ll probably take some time to update StanleyWP to use Twitter Bootstrap 3.2.0, or whatever the newest version is at that point in time.

Anyway, check it out and let me know what you think. There’s a LOT of projects I still need to add, so the list of projects right now is fairly minimal. I am also going to be using that site to take project requests.

If you need a portfolio site and would like to use StanleyWP, let me know if you need help fixing up the grid issues. It’s very simple to do, but may not be so simple for someone who isn’t a developer, like a designer. :)

Meet Unyson, A Drag & Drop WordPress Framework

Features a visual drag & drop page builder that will let your users create countless pages at a drop of a dime

Got an email from Olga at ThemeFuse yesterday announcing the release of their new drag & drop WordPress framework named Unyson.

Unyson comes with many built-in extensions, and the documentation seems to be very helpful and complete. Some highlights from the Unyson home page:

  • All the built in extensions & options work in perfect harmony. You’ll find developing on Unyson a breeze.
  • Your users will love the drag and drop page builder and the customization options built into
  • All you need to do is download the Unyson WordPress framework and start developing your theme.
  • We have a lot of tools ready to help you along the way: developer manual, Trello, GitHub Support and more.

Unyson also includes an extensive list of customizations and options:

  • Page Builder
  • Option Types
  • Styling
  • Sidebars
  • Megamenu
  • Backup
  • Sliders
  • SEO
  • Breadcrumbs
  • Portfolio
  • Custom Widgets

I enjoy this theme so much because it has many features that premium or paid themes have, but Unyson is free! You can download the source on GitHub.

Getting started with Unyson is extremely easy, but slightly different than how you’d typically upload a theme. Installation of Unyson is like so:

  1. Download the framework archive from the framework’s GitHub repository
  2. Extract it to your parent theme directory. After this you must have framework/ directory in parent theme. It’s mandatory to have this exact same folder structure otherwise it will not work.
  3. Include the Unyson framework by adding this line in your theme’s functions.php:

require_once TEMPLATEPATH .'/framework/bootstrap.php';

After that, you’ll need to add some more code to the beginning of all the PHP files associated with your theme. I suggest you go over the Getting Started guide and really pay attention so you get a good understanding of what Unyson can do. The documentation is really awesome, most issues or questions you could have are more than likely covered in the docs.

I haven’t had much of a chance to play with Unyson, but will get the opportunity to on an upcoming client project, so I’m really looking forward to that.

Unyson is quite new, so hopefully we will see more features as it matures. It’s definitely worth checking out.

Growth Hacking WordPress Plugin from Qunb

I’ve been using qunb for quite a while. They generate what they call datastories for your sites using Google Analytics data. The datastories include data like number of visitors, top countries, and most viewed pages. They do a really nice job of presenting your analytics data in a more human readable fashion, a good birds-eye view of it all.

I got an email from qunb announcing the release of their WordPress plugin, Growth Hacking Analytics by It’s available in the WordPress plugin directory.

After installing the plugin, you’ll need to authorize it to use your Google Analytics account. You can also connect your Facebook page and Twitter account, but those don’t require any special permissions.

Qunb has also setup a Google Group that will host discussions about bugs and ideas for improvements. As of this post, however, the Google Group gives me a page titled “Authorization Failed“, with a message stating “Please sign in with an authorized account to view this content“.

The WordPress plugin will add a new sub-menu to the main Dashboard menu. It has 4 main parts to it. The first shows stats about visitors or pageviews, you can select which you want to view. The second part shows pageview stats on the most recent post. The third part, titled Tops of the day, lists your top posts, best social network in terms of referrals, and the best non-social referrer. The fourth and last part displays the growth comparison compared to the last week. You can also view growth comparison for the last month, but you’ll need to have a paid qunb account for that.

The starter plan is $5/month and includes unlimited datastories, and there’s no limit on the number of websites you track.