Latest blog posts

Quick Wins in Laravel

Public Speaking

On the 20th of April, I gave a talk at the Full Stack Ghent meetup. I shared some tips that help me in my Laravel workflow, so my talk was called “Quick Wins in Laravel”.

If you missed my talk my slides can be found on Slidr.io.

During the evening there were 8 talks in total, all on different topics such as CSS, IoT, Astro, PHP, Accessibility, Kubernetes, Regexes, and my talk Laravel. It was my very first public speaking experience, and directly for a larger crowd than a regular meetup, about 130 people showed up that evening.

And lastly, I want to thank the organizers (Dries, Freek and Rias) for making this event possible, and also my friend Bramus for giving me that push to take the stage.

Also, I kinda liked the public speaking thing, so you’ll see me on a lineup somewhere in the future.

Share this post

Is PHP dead? NO it’s not…

Development

The guys at OfferZen Origins used the footage that didn’t make the documentary on Laravel that was released last month, to create this video on PHP.

So all their memories are of, “Oh, here’s how PHP existed in 2005” or something like that.

Jeffrey Way

Share this post

Mailgun “On behalf of” issue

Development

We all know the feeling when we release a new project, we are overexcited until the first email goes out…
All of a sudden a client informs you, “Hey, the email I received has a strange “from” address. Can you fix it?“…

What is happening?

Even though we’ve registered our domain with Mailgun, made sure the correct DNS records are in place. And in our application, we’re using the correct API key combined with the domain and optionally the specific server that we prefer.

The “from” address in the email appears to be info=example.com@mg.example.com on behalf of info@example.com. which isn’t the address we wanted it to be, ideally it should be info@example.com

Mail::send(['html' => 'emails.template'], $data, function($message) use ($subject, $user){
    $message->to($user->email, $user->name);
    $message->subject("$subject");
    $message->from("info@example.com");
});

This issue is caused by the fact that we are using another domain, a subdomain, to configure Mailgun. This is advised, otherwise, we would endanger the normal mail functionality of the domain, if there are any in place, such as Google Workplace or Office 365.

It is the mismatch between the domain used to send our email (mg.example.com) and the domain indicated as the “from” address in our app (example.com).

Mailgun’s suggestion

Mailgun suggests a solution on its website. You can find it here.
The suggested solution may endanger the normal mail functionality as described above. Because we would overwrite the SPF record on the main domain. Which isn’t ideal.

A quick and easy solution

In Laravel, we can specify the sending domain in the email headers. For this, we can use the ->sender attribute.

Mail::send(['html' => 'emails.template'], $data, function($message) use ($subject, $user){
    $message->to($user->email, $user->name);
    $message->subject("$subject");
    $message->from("info@example.com");
    $message->sender("info@example.com");
});

By doing so we enforce the email sending address and the visible “from” address to be the same.

There, the job is done. Happy customer.

Share this post

View all blog posts

Sport stats this year

Ever since my childhood I’ve been passionate about cycling. So when I get the chance, I’m out for a ride. Road Bike or Mountain Bike it doesn’t matter.

Running has never been my strongest. But I’m trying as hard as I can.

As a former swimmer this may be the sport where I’m least active…

Cycling

00 km

Running

00 km

Swimming

00 km

Partners