Whitelisting an email or domain in Mailgun

Recently a client who uses Mailgun to send email from their website had a problem where one of the clients own email addresses had been “suppressed” in Mailgun, meaning Mailgun would no longer send email to that address. It was caused by the client’s mail server having a problem for long enough that Mailgun decided they couldn’t send email to the particular address.

Mailgun have the ability to “whitelist” individual email addresses or whole domains so they will not stop sending to them. That’s exactly what I needed to put in a long term fix for this problem. It’s not available through their website, but you can do it through their API. That was fine, we’re using the API for other things so I can adapt some code to use it for this.

Unfortunately, the docs for whitelisting an email address are currently incorrect. I had some back and forth with their support people and they gave me the following curl example for how to whitelist an email address:

curl -i -X POST  -u api:[your api key] https://api.eu.mailgun.net/v3/[your mailgun domain]/whitelists -F address=[your email address]

Where [your api key] and [your mailgun domain] and [your email address] get replaced by your details.

Remember that if you’re in Europe, you’re probably using the EU API, not the one in the docs, so you’ll need to change the API domain to https://api.eu.mailgun.net

To whitelist a whole domain, use:

curl -i -X POST  -u api:[your api key] https://api.mailgun.net/v3/[your mailgun domain]/whitelists -F domain=[your email domain]

Finally, to check the whitelist, use this:

curl -i -X GET  -u api:[your api key]  https://api.mailgun.net/v3/[your mailgun domain]/whitelists

This was a frustrating situation as it took a while for their support to understand that giving me back the incorrect examples from the docs wasn’t helping, but they did come through for us in the end and were polite and trying to be helpful throughout. Hopefully they’ll get their docs updated soon.

Using ACF Blocks by default in a new post in WordPress

One of my clients has a website using Advanced Custom Fields (ACF) Blocks to style everything in the site, including their News section.

To make a new post in News, they had to load a Pattern of the relevant Blocks. This being a multi-step process, and a bit annoying if you just want to get on with posting your article, I looked for a way to load the blocks into the new post by default.

You can do this by putting this code in your functions.php (with amends explained below)

function site_post_register_template() {
    $post_type_object = get_post_type_object( 'post' );
    $post_type_object->template = array(
        array( 'my-blocks/news-header' ),
        array( 'my-blocks/news-article' ),
        array( 'my-blocks/news-article-related' ),
    );
}
add_action( 'init', 'site_post_register_template' );

In this case, I have three Blocks loading – the specific header, the article, and a strip of related articles. I can load in as many Blocks as I want.

To make this work for you, find where you have saved your blocks and list them out in the same way, in an array for each.

You will have to change ‘my-blocks’ to the prefix of your ACF Blocks. To find that prefix, go to the directory where you store the code for the relevant Block and open the block.json file. Copy the details from the “name” line to be inside the array( '' ), above.

Now, when a new Post is started, it automatically loads in the ACF Blocks and my client can get on with posting their news, not thinking about how they load in the Pattern and where they left my instructions for doing so.

New website for G2 Legal

I am delighted to announce the launch of a new website for legal recruitment agency G2 Legal.

Screenshot of a recruitment website showing their main branding and some legal jobs

The G2 Legal website from 2017-2024

Screenshot of a new recruitment website showing their main branding including a woman and their tagline Passionate about matching talent

The new G2 Legal website (click for larger)

I have a very long relationship with G2 Legal, this is the seventh complete website I’ve helped build for them and it was very much a group effort.

The Team

Amy Walker – Head of Marketing at G2 Legal – acted as primary contact and driver of the project. She handled researching and collating all of the company needs, boiling them down to the necessities and messages that can fit on a website, writing all of the content, and a huge amount of project management. This website does a great job of representing the company, and that is down to her and the work she put in both with Nick and the whole project.

Nick CarterStudio Gallant – design and UX. Nick is a fantastic designer and I’ve collaborated with him on several websites for clients. As usual, he did a fantastic job of taking the client brief and making a design that is contemporary, professional, and will stay fresh for many years. He worked closely with Amy to make sure G2 Legal got what they needed from this project and I think he did a very, very good job.

Jim LesterZero1Zero – front end build. Jim came highly recommended by Nick and I can see why. He made a great translation of Nick’s designs into working templates with clean, understandable HTML, CSS and Javascript in short order and was more than helpful when we had some late additions to the project. He was a delight to work with and I hope I get a chance to again in the near future.

Paul SilverSilver Web Services – back end build, integration of front and back ends. More on my part below, but in brief I handled moving the website from one set of back end code to another, took Jim’s templates and turned them into a working site which can be edited by the staff at G2 Legal, and handled various search engine optimisation tasks.

The site became a much larger project than planned and I am delighted with the way it has come out. Thank you to everyone who was involved with the project, I hope you’re as proud of the outcome as I am.

My part of the project

Laravel to WordPress

Being a programmer, most of my work is hidden away. Previous versions of the website were editable by the staff at G2 Legal, but the content management features were little used and had therefore not had much in the way of updates for over ten years. Now, the company has an active marketing department headed by Amy and the website needed to change. Their main requirement from the tech was to have a site they could easily edit and preview changes so they could see the pages as they would be published, not just parts of them.

The previous site was based on Laravel and various custom code written by myself and Laura Tyler. I assessed various Laravel based Content Management Systems (CMS) to see what we could add to the existing code base to do what was required, but I found them all rather lacking from a user experience viewpoint. The people updating the website are not techies and should not need to become ones in order to get their job done. I looked further afield for better tech.

WordPress for a modern editing experience

A solution came thanks to Hazlitt Eastman, who showed me a project he was making in WordPress using their latest editor with helpful additions from Advanced Custom Fields. It gives the site owner a very good editing system and preview and allowed me to get very close to the perfect experience for the client within their budget. Hazlitt kindly gave me a training session in how to set up the “blocks and patterns” involved in making the editing system pleasant to use and extra technical support across the project. Big thanks to Hazlitt for this, he got me out of several technical holes.

A lot to port

Originally I was thinking I’d use Laravel to run an API which the WordPress site would make requests to. For most of the site, that turned out not to be the right choice when I looked at the long term maintainability of the code, and considering at some point they may want another developer to work on the project. So, most of the backend code moved from Laravel to WordPress style PHP. The site may look simple, but there are a lot of hidden depths to it, including a very advanced job search both on the backend and with a new experience on the frontend which meant writing new APIs, which WordPress easily handled, and a lot of Javascript.

The intricacies of moving all of the code was a much larger task than I expected, but I think gives us advantages over the short and long term: the speed of response of the website wouldn’t have been as fast if I had stuck with my original plan, and changes over time would have been more convoluted as we’d be working with two quite different styles of codebase rather than just one within WordPress.

Looking at the long term

The previous website was live for a little over six years and went through many changes as company needs changed. It ended up as a bit of a patchwork of the original and new looks and features. I’m confident this site is flexible enough to work with changes G2 Legal needs over the coming years and will still look good at the end of it.

Hear’s to Amy, Nick and Jim for all the help getting it there with me.

Also posting on the Farm and Skiff blogs

I haven’t been posting the Farm write ups here as I moved them to the new Farm blog, which Haze added to the Farm site for me. I’m writing up the topics we talked about from each meet up, and trying to add some more information with one or two ‘highlights’ where I can go into a little more depth. Trying to keep this to something that doesn’t take up too much time so I can make it sustainable is difficult.

Similarly, I have been writing regularly for The Skiff blog. There are lots of in-house events happening at The Skiff, the coworking space in Brighton that I’ve used for many years, and I thought we should be documenting them in some way as it’s easy to lose track of what has and hasn’t happened over the long time it has been running. Also, seeing what is happening in The Skiff may help it attract some more members and stay open, a very good thing in my book.

For the Farm, I have a lot of posts I can make retroactively. I have notes from about 800 of our weekly meetings, I just need to find time to write something to import them into a database so I can export them to a format WordPress can import. Currently I’m thinking of exporting as a CSV and using an import plugin to bring them in, rather than learning the WordPress API as that will take more time and make it less likely I’ll get around to doing it. But currently, client work is taking priority as I’ve got a new site build in progress for G2 Legal, and a bunch of smaller work on too. More about that as I finish parts of it, hopefully.

Farm report – 22nd March 2023

Last week at the digital freelancers networking event I put on every Wednesday, we had a special early start. Last year I surveyed members to see what would help them get more out of the Farm group and a few said they found it difficult to make it as we’re on quite late. Normally we meet 8pm until about 11pm.

I said I’d try some starts at 6pm to see how attendance went. This was the third time I’ve tried that, the first time in 2023. It was by far the best attended, with over a dozen people turning up between 6pm and 8pm, and seventeen people in all across the whole evening.

A lot of the attendees would have come anyway, just later, but we did have a couple of people who couldn’t have made it otherwise. So, it looks like I’ll try to make a 6pm start happen more regularly. It certainly won’t be every week as it depends on my being able to work in Brighton during the day.

Here’s some of what was talked about over the evening:

  • Finding time for personal projects
  • Tiredness post-Covid
  • Strategically placed doilies
  • Show & Tell at The Skiff
  • Choosing a new coworking space / shared office
  • Sussex Azure meet up
  • Saving money on your AWS bill
  • Publishing jobs to various places for recruiters
  • Retrocomputing
  • Motivation
  • Looking for design work
  • AI tools and how they might effect what we do
  • Welcoming people back to a project
  • ChatGPT writing code
  • AI coming for tech jobs?!
  • The terrible state of the economy
  • Is there less work around than usual? – comparing notes
  • “He drew shrimps on it”
  • Buy to Let landlords changes due to tax and interest rate rises
  • Politics and religion
  • Giving up smoking and vaping
  • The prices of Brighton area projects over time
  • Pub management change a comin’
  • What will happen to the Sussex Yeoman pub?

Highlights

Saving money on your AWS bill

Anthony talked about a recent piece of client work where he’d reduced a hosting bill from AWS by over £600 a month. An excellent job for his client! Talking with him and Haze, who had a similar success a few years ago, I got ideas of what to look for in client setups within Amazon Web Services, and how complexity can creep in. This can be accidentally through inexperience or deliberately through fiefdom building. I also heard about areas to watch out for, such as storage which is always virtual and never saved to disk – very risky as if your virtual server is ever rebooted or AWS have an outage, you’ll lose all your data.

Is there less work around than usual? – comparing notes

This conversation took in several members. In the last couple of recessions, there has been a lot of work around for freelancers. This was generally driven by companies making their web departments redundant and wanting more flexible workers, and by a trickle down of work as budgets tightened and clients who would usually use small agencies turned to freelancers instead.

This time, the economy has tightened – although we’re not in an official recession – but there aren’t as many offers of work around as usual. This doesn’t mean there isn’t work out there, but you need to hunt for it more than before. One member who is coming back from a bad case of Covid has recently picked up work thanks to someone else in the Farm, and now the various feelers he’d put out are returning enquiries he can’t fulfil. A year ago, and certainly pre-Covid, those feelers would have got him work much faster than now. I’ve known him get fully booked within a couple of days of starting looking.

It’s getting to desperate times, but it’s good to know there is work around if you put decent time into looking for it.

Tiredness post-Covid

One of our members had a bad case of Covid over Christmas and although they’re able to work again, they are affected by an unusual level of tiredness. They’re coping with this by restricting themselves to working the equivalent of three days a week. Fortunately, they are someone who has been very hardworking and successful in the past and had a financial plan in place that has and is covering themselves.

When you’re freelance, this is the sort of thing that can wipe you out financially – enough bad luck and even in the UK, where our healthcare is covered by our taxes, you can still end up in a terrible position.

For me the lessons are: make sure you have some savings you can draw on in case you get sick, especially now Covid is so prevalent, and make sure you don’t work too hard when you’re first back from a bad illness. Whatever you’ve been suffering from, don’t try to launch straight back into a full calendar after you’ve been badly ill.

You’re a freelancer, you can control your hours. Say you’re available three days a week, or two, or whatever you need. The client doesn’t need to know why, they just need to know you’re tied up at the other times. As you get your strength back, you can increase your hours back to normal.

Strategically placed doilies

I’m not going to properly explain this. It’s to do with a gentle prank one member played on another and I know both will be tickled by it being in the notes when they see them. Like “he drew shrimps on it,” I like to have something bizarre that’s come up during the night and will never make any sense if you weren’t there. The best way of finding out is to come along.