Find the bandwidth hog by viewing all network connections passing through your DD-WRT router
Something was using all of my upstream bandwidth, wasn’t sure what device or who it was (had friends over). To get to the bottom of it quickly, a simple command can be run from the DD-WRT web-based gui that will show all network connections on your DD-WRT router.
Just follow these 5 easy steps below:
1. Login to your router’s web interface.
2. Click the “Administration” tab, and then click the “Commands” tab.
3. In the text area to enter commands, enter this:
4. Click the “Run Commands” button below where you entered the command above.
Once you’ve clicked the “Run Commands” button, wait a few seconds, and you’ll eventually see some output similar to what you see in the image above, below is the raw text from the image:
Now the key to tracking down the offending user/device is to look for a source IP (almost always a non-routable IP, like 192.168.1.x, 10.10.10.x or whatever) that shows up a LOT more often than other non-routable IP’s.
Once you’ve found that IP, go to the “Status” tab in the DD-WRT web interface, click “LAN”, find the IP that you suspected was the culprit from above and make a note of the MAC address associated with that IP.
Manipulate Mailgun Bounce Lists: Show, Add, and Delete Email Addresses. All from the terminal.
I recently came across a situation where a client reached their disk usage limit. As a result, they were unable to receive emails. This went un-noticed for a couple days (I didn’t manage the server at the time, I do now).
Bounce list stores events of delivery failures due to permanent recipient mailbox errors such as non-existent mailbox. Soft bounces (for example, mailbox is full) and other failures (for example, ESP rejects an email because it thinks it is spam) are not added to the list.
Subsequent delivery attempts to an address found in a bounce list are prevented to protect your sending reputation.
I first noticed the bounce issue in the logs, like in the image below. After not being able to find a way to manage email addresses on the bounce list from the browser, I hit up Google and was pleased to find that you can interact with Mailgun bounce lists via their API.
Show Email Addresses in the Mailgun Bounce List
To list email addresses on the bounce list, do something like this on the terminal/command line, replacing key-xxx-xxx with your actual Mailgun API key:
You can find your Mailgun API key on the Mailgun dashboard, under API Keys. The Mailgun API will return JSON, which is a bit difficult to read in the terminal. I usually copy the output and paste it into this JSON formatter, which makes the data much easier to read, as you can see in the screenshot above.
Even when the formatted JSON in it’s raw form is easier to read. See, here’s the returned JSON, in it’s original form:
Now here’s the pretty, formatted JSON as raw text:
Much easier to read, right? Those of you using REST clients like Postman will have your results automatically prettified, removing the need using a site like the JSON formatter I typically use.
Delete an Email Address from the Mailgun Bounce List
If you’ve found an email address you’d like to remove from the Mailgun bounce list, or already know the email you want to remove, do this from a terminal and replace [email protected] with the real email address to delete. And of course, replace key-xxx-xxx with your actual Mailgun API key:
Sometimes you may wish to manually add an email address to the Mailgun bounce list. This can be done very easily with the CURL command below. It will add [email protected] to the Mailgun bounce list, so make sure to change that to the email you really want to add to the list.
Not much concerning Mailgun bounce lists specifically. It’s possible to add multiple addresses to a bounce list at once, but that gets a little more difficult from the terminal as it requires sending JSON to the Mailgun API. Using a client like Postman would be a better option if you intend on sending much data.
The Mailgun API can be used to do all sorts of stuff, like pull stats and to create new domains. It’s a powerful API and one of my favorites to work with.
Simple Tutorial Showing How To Use Composer in Your WordPress Plugin or Theme
I love Composer. It just makes including libraries or scripts in your app incredibly easy. So easy that it’s stupid not to use it (in many, if not most cases).
The number of libraries/scripts available on Packagist is astounding, all of which can be included in your plugin with Composer. Packagist is the main Composer repository. It basically aggregates all types of PHP packages that can be installed via Composer.
I’d never used Composer with a proprietary WordPress plugin before. The plugin is for a client so it’ll never be available to the public.
Here’s the steps I took to make this WordPress plugin compatible with Composer so that I can easily bring in third-party libraries.
We’ll be using mailgun-php throughout this example, as the plugin that inspired this post uses Mailgun to send all sorts of emails.
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
sudo apt-get 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:
# Gmail/Google Apps
from [email protected]
user [email protected]
# Default account to use
account default : gmail
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.
3. Remove Sendmail
sudo apt-get remove sendmail-bin
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.
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:
sendmail_path = "/usr/bin/msmtp -t"
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:
if(mail("[email protected]","A Subject Here","Hi there,nThis email was sent using PHP's mail function."))
print "Email successfully sent";
print "An error occured";
6. Disable IPv6 If You Experience Slowness
Open up /etc/gai.conf like so:
sudo nano /etc/gai.conf
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.
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.
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:
That’s all that’s required to add schema.org 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.
%d bloggers like this: