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

TutsPlus.com:
Send Emails in PHP Using the Swift Mailer
Jun 12, 2018 @ 18:18:59

On the TutsPlus.com site, they've posted a new tutorial showing you how to use one of the more popular (and longest running) mailer projects in PHP: Swift Mailer. In this tutorial they introduce you to the tool and share some code showing it in use to send basic emails.

In this article, we're going to explore the Swift Mailer library that allows you to send emails from PHP applications. Starting with installation and configuration, we'll go through a real-world example that demonstrates various aspects of sending emails using the Swift Mailer library.

The article starts with a brief introduction to the Swift Mailer library and what kinds of features it brings to the table. It then shows the installation via Composer and how to include it into your application (autoloaded, naturally). Code is then provided showing how to send emails and includes examples of sending BCCs, attachments, setting the "from" and setting the body contents. It steps you through each part of this sample code and explains what it is doing and other options it could include.

tagged: tutorial send email swiftmailer introduction package composer

Link: https://code.tutsplus.com/tutorials/send-emails-in-php-using-the-swift-mailer--cms-31218

Sergey Zhuk:
Sending Email Asynchronously With ReactPHP Child Processes
May 04, 2018 @ 14:42:27

Sergey Zhuk has a new tutorial posted on his site showing you how to use child processes in ReactPHP to send emails asynchronously using Swiftmailer.

In PHP the most of libraries and native functions are blocking and thus they block an event-loop. For example, each time we make a database query with PDO, or check a file with file_exists() our asynchronous application is being blocked and waits. Things often become challenging when we want to integrate some synchronous code in an asynchronous application. This problem can be solved in two ways: rewrite a blocking code using a new non-blocking one or fork this blocking code and let it execute in a child process, while the main program continues running asynchronously.

This first approach is not always available, asynchronous PHP ecosystem is still small and not all use-cases have asynchronous implementations. So, in this article, we will cover the second approach.

He starts by creating the main HTTP server handler running locally on port 8080. He adds in an exception handler to catch potential issues and provides example code of an exception being thrown. With that structure in place he starts on the Swiftmailer integration, adding it to the exception handler and pushing the details of the exception into the message body. This is then modified to use the react/child-process package to wrap a new PHP file inside of a child process loop. The tutorial ends with an example of how to pass data between the parent and child process. In this case it's the message from the exception.

tagged: send email child process reactphp tutorial exception asynchronous

Link: http://sergeyzhuk.me/2018/05/04/reactphp-child-processes/

TutsPlus.com:
Notifications in Laravel
Apr 24, 2018 @ 18:25:24

On the TutsPlus.com site they've posted a new tutorial for the Laravel users out there showing how to work with notifications, a feature build into the framework to make it simpler to provide information to users when certain events are triggered.

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications over the mail channel.

The tutorial starts with some of the basics of the notification system including a mention of the other methods (like SMS and Slack) and storing them in a database for other interaction. It then moves on to the creation of a Messages model and a custom notification class to send email to a when a new message is sent from another user. With the class created, they move into the process required to send the notification using the Notification::send method.

tagged: laravel tutorial notification email custom message

Link: https://code.tutsplus.com/tutorials/notifications-in-laravel--cms-30499

Freek Van der Herten:
How to send a "trial expiring soon" mail in Laravel Spark
Jan 15, 2018 @ 16:10:02

Freek Van der Herten has posted a guide to sending an email in a Larvel Spark-based system to remind a user that their trial of a service is expiring soon. In this case, it's a monitoring service he offers called Oh Deal.

I'm currently building a webapp named Laravel Spark, a Laravel based template to kick off SaaS projects. It offers logic for organising users into teams, handles trial periods, subscriptions, payments, invoices and much more.

[...] Unfortunately, Spark will not send out a mail to team owners whose teams are in trial periods that will soon expire. Luckily it's easy to add that yourself. I'll show you how to do just that in this post. Along the way, you'll learn some good general tips for sending out emails in batches. Let's get started!

He then starts in on the code, showing first how to locate the teams that should be sent the email. He adds a new field to track when the email was sent and the code required to send the actual email. He shows how to make the command restartable, create the "Mailable" class and the command to send the actual email.

tagged: team tutorial ohdear ending trial spark laravel mail email

Link: https://murze.be/how-to-send-a-trial-expiring-soon-mail-in-laravel-spark

TutsPlus.com:
How to Send Emails in Laravel
Jan 05, 2018 @ 18:25:33

The TutsPlus.com site has posted a tutorial for the Laravel users out there showing you how to send emails with built-in functionality via the framework's Mail API.

In this article, we're going to explore the Mail API in the Laravel web framework. Laravel takes advantage of the popular SwiftMailer library, which is easy to use and comes with a variety of email drivers to choose from. In the latter stages of the article, we'll go through an in-depth demonstration of the concepts discussed in the first half of the article.

The tutorial starts with the setup and configuration you'll need to get the mail system up and running. They don't help you set up the backend (like sendmail or Mailgun) but they do describe the options in the configuration required for methods like SMTP sending and local sending. Next they show an example of a "mailable" class that creates a "demo" email and defines various settings including the "from" address, the content (from a view), variables to pass to the view and an image attachment. The view for the example is also included, making use of the Blade templating to replace placeholders with variable values.

tagged: email laravel tutorial mailable class example

Link: https://code.tutsplus.com/tutorials/how-to-send-emails-in-laravel--cms-30046

Laravel News:
Inbound Email in Laravel
Aug 15, 2017 @ 16:39:02

The Laravel News site has posted a tutorial showing you how to handle inbound email using the framework and Mailgun's inbound routing feature (essentially webhooks)

I recently needed the ability to receive emails and process attachments on those emails. I love Mailgun for the sending of transactional email, so when I needed to process incoming mail I started digging into Mailgun closer and realized their powerful inbound routing email features!

Come along and learn how you can set up a webhook to process inbound email and secure it within your Laravel applications. We will even use Laravel Valet (or ngrok directly) to test it out locally!

They start by talking about inbound routing: what it is and how it works using a request back from the Mailgun service. They briefly walk you through the setup of a Mailgun account and your DNS to use it for mail service. Next they create a new Laravel project, configure it for email with Mailgun and create the hook the webhook from Mailgun will reach back out to. They use Valet to share it via ngrok and configure the Mailgun account with the resulting URL. The post finishes up showing how to secure the webook via validation middleware and how to test it. They also share a few tips you can potentially use in the controller like using jobs for response handling and working with files.

tagged: tutorial inbound email laravel mailgun webhook callback

Link: https://laravel-news.com/laravel-inbound-email

CloudWays Blog:
Laravel Notification System On Slack And Email
Jul 27, 2017 @ 20:49:59

On the Cloudways blog Saquib Rizwan has continued the series showing how to use Laravel to build out an application the performs various kinds of notifications. In this latest article Saquib

In my previous articles, I helped you create a Laravel email sending system and a Contact Us form.

In this article, I will highlight another amazing feature of Laravel through a very basic Laravel notification system. Using this system, I will send a notification to the user by sending them an email and integrate Slack to setup the system for sending notifications on a Slack channel.

They start with setting up a new Laravel application, creating a "users" table and setting up the database. These instructions are for the Cloudways service but they give you an idea of what needs to be set up at least. Next is the code to set up the User model and to create a new notification for a "visit" to the page. First up is the email notification then comes the Slack notifications. Both use built-in functionality with the "Notifications" package in the framework to make the sending work.

tagged: tutorial laravel notification email slack introduction

Link: https://www.cloudways.com/blog/laravel-notification-system-on-slack-and-email/

Paul Jones:
Domain Logic and Email Templates
Jul 18, 2017 @ 16:59:50

Paul Jones has a new post on his site sharing some of his thoughts about the placement of domain logic and email templates in an ADR (Action/Domain/Responder) structure. The post is an answer to a recent question he received asking how to organize emails being sent by service classes.

In a way, sending an email as part of a web request/response cycle is like sending two responses: the normal HTTP response, and the email response. With that in mind, it might make sense to think of the HTML + Text email templates as part of a presentation layer. Or, as a combination of infrastructure (the email-sending client) plus presentation (the templates). That would be how to think about the separation of concerns there.

He then provides what he sees as a good directory structure to help keep it all separated out. He also talks about the load sending emails can put on a system, when to move it to workers and how that impacts where the templating of the emails should be done.

tagged: domain logic email template adr actiondomainresponder designpattern structure

Link: http://paul-m-jones.com/archives/6619

Cal Evans:
Mautic Step 1 – Configuring an Email Service Provider
Jun 26, 2017 @ 15:30:17

Cal Evans has continued his series covering Mautic, the PHP based self-hosted marketing automation platform. This is step one in the process with his previous post in the series introducing Mautic and why he's trying it out.

This is the second post in a series titled “My Journey into Mautic”. If you are starting here, you might get an incomplete picture, you may want to check out the previous articles.

There are two things that really confuse me about Mautic, properly configuring an Email Service Provider (ESP), and segmenting & tagging. We’ll tackle the latter one in a later post, but the former is an important topic. It is also one that I do not fully understand. What is presented here is what I have learned through trial and error. it my be partially or wholly incorrect. If you find something that I’ve gotten wrong, please, by all means, correct me in the comments.

He starts by defining what an ESP service is and what it's useful for. While he had done the self-hosted email server in the past, he recommends paying for a service these days, deciding for his needs on Mailgun. He covers the difference between transactional and broadcast emails followed by the setup process he followed to get Mailgun up and working with his Mautic install.

tagged: series mautic marketing automation selfhosted platform tutorial email service provider

Link: https://blog.calevans.com/2017/06/25/mautic-step-1-configuring-an-email-service-provider/

Cloudways Blog:
Create A Contact Form In Laravel That Sends You An Email
Jun 23, 2017 @ 16:17:02

On the Cloudways blog they've posted a tutorial showing you how to create a simple contact form that emails when someone fills it out and the information they submitted.

Laravel is well known for providing multiple solutions for a problem. This is one of the main reasons of the popularity of the framework. Popular Laravel solutions cover routine functionality such as authentication, sessions, routing, and caching.

Contact Us forms are another routine functionality that is a requirement of more or less every website. In this article, I am going to demonstrate how you can easily create a contact form in Laravel with email. To understand the functionality of Laravel mail function. I suggest you read my previous article on sending emails in Laravel.

The author then walks you through the installation of a new Laravel application on the Cloudways service. He then shows how to install the "Form" package (laravelcollective/html) and enable it as a service provider. Next up comes the database configuration and the creation of the table to handle the data submitted via the "Contact Us" form. The model is then created to work with the table, the route is added to show the form (and handle the submission) as well as the matching view and controller. The post wraps up with the commands and configuration you'll need to send the emails and an example of a "mailable" class to handle the email's construction.

tagged: tutorial laravel contact form email simple

Link: https://www.cloudways.com/blog/laravel-contact-form/


Trending Topics: