Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Scotch.io:
The Ultimate Guide to Sending Email in Laravel
Apr 01, 2016 @ 12:35:21

On the Scotch.io site today there's a new tutorial giving you the ultimate guide to sending emails in Laravel - from choosing your provider out to sending both text and HTML emails (some with attachments).

Sending emails in web applications has become so essential. Marketing, notifications, newsletters, adverts, etc are some of the reasons why we send emails to our clients. I'd say the majority of websites send automated emails at least via a "Contact us" form.

Let's explore the many possible ways to send emails in a Laravel application.

They start off with a brief look at three different services you can set up out of the box with Laravel: Mailgun (for regular sending), Mailtrap (for debugging) and Mandrill (for bulk emails). They show you how to configure each service in Laravel and setting one of them up as the default. The tutorial then gets into sending the actual emails through a simple EmailController::send endpoint. They show the code to set up the Mail. They show examples of what the resulting emails look like and how they show up in the related mail services. There's also instructions on attaching files, using queues to optimize email sending and a "bonus" about sending bulk emails with MailChimp.

tagged: send email laravel tutorial ultimate guide mailchimp mailtrap mailgun

Link: https://scotch.io/tutorials/ultimate-guide-on-sending-email-in-laravel

Scotch.io:
Why Laravel Queues Are Awesome
Mar 18, 2016 @ 10:08:42

In a new tutorial to the Scotch.io site they take a look at Laravel's queuing functionality and explain why they think it's awesome for handling asynchronous operations in your applications.

Otwell took his time to build Laravel and it's documentation and one of the major features that really amaze me is what we are going to experiment with, Queues.

Queues in Laravel are used to make a smooth sailing application cycle by stacking heavy tasks to be handled as jobs and dispatching these jobs when it is asked to or when it does not disrupt the user's experience.

They then show how to use the queuing system to send out emails asynchronously rather than waiting for them to send via the application and making the user wait. First they show how to send them a bit more manually, making use of the Mailtrap service for testing the emails being sent. They set up a basic controller with a "send" endpoint that uses the Mail functionality to send a simple HTML email. Next they show how to refactor this into something that uses queues to handle the email sending via a SendWelcomeEmail job. He talks about performance differences between the queued and non-queued version and links to a demo repository if you'd like to see it all working together.

tagged: laravel queue tutorial introduction email mailtrap

Link: https://scotch.io/tutorials/why-laravel-queues-are-awesome