Fixing a data truncated warning in MySQL

How I fixed my “data truncated for column” warning in MySQL

Recently, while working on a project, I ran into a warning telling me that my “data was truncated for” one of my columns when I was importing a CSV file into one of my SQL tables.

Data truncated warning in MySQL
Pictured: The error in question.

Concerned that I had done something wrong, I Googled for a solution. Unfortunately, I didn’t find any answers there, so I ended up having to find the source of this warning myself.

Continue reading
Setting up a virtual Postfix mail server — Part 3

Setting up a virtual Postfix mail server — Part 3: Implementing DKIM, DMARC and rDNS

In the previous part of this tutorial series, we set up a mail server that could accept connections from mail clients like Gmail. This allowed us to send out domain emails using a mail client, instead of having to implement a mailbox on our server.

With our mail server’s basic functionality properly set up, we can now turn our attention to another problem — email deliverability. Spam email is a really big problem online, so many email providers have some kind of system in place to assess whether an incoming email is spam and either flag it, or reject it. Hence, after setting up our mail server, one thing we need to do is to ensure that our mail server conforms to certain email security standards, policies and protocols. This goes a long way to help us communicate to other mail servers that we are trustworthy, so that our emails will be deliverable.

Continue reading
Setting up a virtual Postfix mail server — Part 2

Setting up a virtual Postfix mail server — Part 2: Sending emails with SASL

In the first part of this series, we set up a basic virtual mail server with Postfix that received emails for our domain and forwarded it to a mailbox of our choice. To round off the basic set of features for our mail server, we will be setting up Simple Authentication and Security Layer (SASL) to work with Postfix, so that we can access our mail server with a mailbox client (like Gmail) and send out emails from our domain.

Continue reading
Setting up a virtual Postfix mail server — Part 1

Setting up a virtual Postfix mail server — Part 1: Receiving emails with mail forwarding

If you own a domain, and are looking to set up email hosting for it, you have a couple of options. You can either:

  1. Get a generic web hosting service that comes with a cPanel-based email hosting service, or;
  2. Use services like Google Workspace or Microsoft’s Enterprise Email Service.

The former option is cheap, but can be clunky to use and ineffective with blocking spam. The latter option — being specialised services — are generally much more accessible and effective with spam, but cost more.

There’s actually also a third option, and that is:

  1. Running your own mail server on a cloud server.

This means that you have to set up the server and maintain it, but it also means that you can have a cheap and effective mail server, instead of having to choose between one or the other.

In this series of articles, we are going to explore how we can set up a virtual mail server using a Mail Transfer Agent (MTA) called Postfix. This will be a fully-featured mail server, meaning that over the course of these articles, we will be building a mail server that can:

  1. Send and receive emails,
  2. Filter incoming emails for spam, and;
  3. Pass email policy checks, so that the emails it sends out are not flagged as spam.
Continue reading
Importing CSV files into a MySQL table

Importing a CSV file into an SQL table

CSV stands for Comma-Separated Values, and CSV files are text files that look something like this:

example.csv

Username,Email,Address,Contact
johndoe,john@example.com,"71 Pickering Street, Singapore, Singapore",+65-91234567
janedoe,jane@website.com,"24 Raffles Lane, Singapore, Singapore",+65-81234567
marysmith,mary@smith.com,"83 Riveting Road, Singapore, Singapore",+65-97654321
bobsmith,bob@smith.com,"84 Riveting Road, Singapore, Singapore",+65-87654321

Essentially, the CSV file format is meant to represent tabular data. The above CSV file represents the following table:

UsernameEmailAddressContact
johndoejohn@example.com71 Pickering Street, Singapore, Singapore+65-91234567
janedoejane@website.com24 Raffles Lane, Singapore, Singapore+65-81234567
marysmith mary@smith.com 83 Riveting Road, Singapore, Singapore +65-97654321
bobsmith bob@smith.com 84 Riveting Road, Singapore, Singapore +65-87654321

Due to their tabular nature, data in a CSV file can very easily be imported into and stored in an SQL table. The commands to do that, however, are not very well-documented online.

If a CSV file does not open as a text file on your computer, that’s because your computer is opening the file with a spreadsheet program such as Microsoft Excel. In such a case, to see the file as text, you will want to open these files on a text editing software such as Notepad.

Continue reading
Python in XAMPP

Running Python in XAMPP

Are you looking to run Python as a server-side scripting language on your XAMPP installation? Here’s a guide on how to set it up.

Continue reading
Remove the admin bar from the WordPress admin backend

Hiding the WordPress admin bar programmatically on the backend

Whenever you are logged in to WordPress, there is a black admin bar that shows up above every page. On front-end pages, you can call show_admin_bar(false) in one of your plugin or theme functions to remove it. Individual users can also hide the admin bar on their account’s profile page.

All of this, however, doesn’t work if you are on a backend page. No matter what you do, the admin bar will always show up in those circumstances, unless you remove the admin bar programmatically — this article is here to show you how, as well as why you would want to do such a thing.

Continue reading
Why doesn't text-align center always work?

Why doesn’t text-align: center work? A primer on block and inline elements in HTML and CSS

If you’re just starting your foray into web development, you’ll probably find that HTML and CSS have a variety of quirks that can make working with them somewhat frustrating for beginners. One of these quirks involves the text-align CSS attribute, as the attribute only applies its effects to certain kinds of HTML elements.

Continue reading
PHP mail not delivering domain emails to external mail server

PHP mail not sending domain emails to external mail server

Recently, I’ve done some work for a client with an odd issue: the contact forms on their website (let’s call it client-website.com) — which delivered completed form enquiries using PHP’s mail() function — could not send emails through to email addresses containing their own domain.

This means that, if we were to set the form to deliver enquiries to an address like hello@client-website.com, the email would be completely dropped — you would neither find it in the junk or spam folders, nor find any trace of the email in their admin and mail logs. If we delivered the email to our own personal email addresses (e.g. personal@gmail.com), or to emails from another domain (e.g. mail@terresquall.com), then the email would go through (and skip right past the spam folder too).

For weeks, this problem confounded me, until now… and it’s actually a really simple fix.

Continue reading