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

Twilio Blog:
How to Send SMS Reminders from PHP Symfony Applications
Sep 25, 2018 @ 14:42:18

On the Twilio blog today Sylvan Ash has written up a tutorial showing how to send SMS reminders from a Symfony application as reminders of certain events.

If you have a booking system, making appointments such as massage or other therapist bookings, dental or medical appointments, etc., you’d probably like to remind the client about the booking they made on the day of the appointment. In some cases, you might also want to remind the person offering the service. In this tutorial, you'll learn how to send SMS reminders to clients of their upcoming massage appointments, at a designated time before the appointment, in a Symfony project using Twilio's SMS service.

The tutorial starts with a brief description of the setup and uses Composer to create a new Symfony project (the "Appointments" application). It then moves on to the models, defining the structure for the User and Appointment entities. It also shows how to make use of the seeding functionality to create several default users. Next up comes the Twilio integration: installing the SDK via Composer, defining the configuration and adding the client as a service.

With all of that set up, the final pieces are shown: the command to send the SMS messages via the Twilio service and the cron job to run it once a day at midnight.

tagged: symfony tutorial send sms application reminder appointment

Link: https://www.twilio.com/blog/sending-sms-reminders-with-symfony-php-framework

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/

Laravel News:
Learn How to Send an Email on Error Exceptions
Apr 18, 2017 @ 15:25:03

On the Laravel News site there's a quick tutorial posted showing you how to send an email when an exception is thrown in your Laravel-based application using the "mailable" functionality.

You’ve created a new Laravel app for your client and deployed it on the production server. Everything was working fine till a customer has a problem with the app because of some buggy code. He immediately leaves the app, and the same thing happens with multiple customers before you know about the bug. You fix the bug, and then everything is on track.

But what if you were notified immediately through e-mail (or another service) about the bug and you fix it ASAP. In Laravel, this can be done easily and in this post, we’re going to learn how.

The post talks about how errors and exceptions are handled in Laravel applications and how, with a bit of custom code, you can create you own handler and a "mailable" class it can use (an ExceptionOccured mailer) to send a full stack trace when an error is thrown. There's also a link to a package that can be installed that helps to make setup even easier.

tagged: send email laravel exception tutorial mailable handler

Link: https://laravel-news.com/email-on-error-exceptions

StarTutorial.com:
Sending Email with SES in CakePHP 3
Dec 08, 2016 @ 15:31:21

The StarTutorial site has a new article posted showing you how to send email via SES in a CakePHP 3 application. SES is a service from Amazon Web Services that makes it simpler to send emails, the Simple Email Service (SES).

In this tutorial, we will show you how to set up CakePHP 3 to send email with AWS SES via SMTP. In our opinion, integrating AWS SES with CakePHP 3 by SMTP is more straightforward comparing to API.

They start off with the creation of the "EmailTransport" profile configuration dropped into the main application configuration file (defining connection and credential information). They then show how to create an "email profile" telling the framework to use the SES service definition. Finally they offer some advice about using the SES service on a Google Cloud instance and how to work around some of their port restrictions. CakePHP takes care of the rest, automatically understanding how to work with SES and using it transparently as the mailing service when you send your emails.

tagged: cakephp3 tutorial email aws ses send email configuration googlecloud

Link: https://www.startutorial.com/articles/view/sending-email-with-ses-in-cakephp-3

Freek Van der Herten:
Sending a welcome mail with Laravel 5.3
Oct 04, 2016 @ 16:15:35

Freek Van der Herten has posted a new tutorial to his site showing you a method for sending a "welcome" email for your Laravel (5.3) application using the recently added "mailables" functionality.

Recently I was working an a project where, in order to use the webapp, users should first apply for an account. Potential users can fill in request form. After the request is approved by an admin they may use the app.

Our client expected that the barrier to request an account should be very low. That’s why the request form doesn’t contain a password field. Instead, when an account is approved, a welcome mail is sent with a link to where the user can specify a password.

In this post I’d like to show you how we solved this with Laravel 5.3’s mailables.

He starts with a high level overview of what he's trying to accomplish: sending the approval when the admin approves a new user in the system. He includes all the code you'll need to create:

  • the "approve" method in the User model
  • the event handler for the "UserApproved" event
  • generating the password reset hash/token
  • the actual code for the mailable class to send the message

He also includes the view for the email's contents, a simple "WelcomeController" to handle the user responding to the message and the view for the verification and password reset "welcome" page.

tagged: laravel tutorial send welcome email approval mailable event

Link: https://murze.be/2016/10/sending-welcome-mail-laravel-5-3/

Laravel News:
Sending and Receiving SMS with Laravel and Nexmo
Aug 05, 2016 @ 17:36:05

On the Laravel News site they've posted a tutorial from Phil Leggetter showing you how to integrate your application with Nexmo to be able to send and receive SMS messages in your Laravel application.

In this quick tutorial by Phil Leggetter, we’ll cover how you can both send and receive SMS from your Laravel application. We’ll do this using Nexmo, a cloud communications platform that offers APIs for provisioning phone numbers, sending and receiving SMS (which is handy since we’ll use that), making and receiving phone calls and more.

He starts off with some prerequisites you'll need to get the system working (including an account on Nexmo and their command line tool). They create a fresh Laravel application and integrate the Nexmo PHP package into it as a service provider. With that installed he shows how to send an SMS message to a phone number, how to "rent" a number they can reply to and receiving the callback when they send a response. The post finishes with the setup of an "auto-responder" that just confirms that the message was received.

tagged: nexmo laravel tutorial integration send receive message rent number

Link: https://laravel-news.com/2016/08/sending-receiving-sms-laravel-nexmo/

Matt Stauffer:
Using SparkPost for Transactional emails with Laravel
Apr 27, 2016 @ 15:54:42

Matt Stauffer has a post to his site for the Laravel users out there wanting to seed "transactional emails" from their applications. In this tutorial he shows you how to use the SparkPost service to send emails with very little effort.

Recently, Mandrill announced that they'd be sunsetting their transactional email service and instead rolling it in to a secondary service for paid MailChimp users. That's fine for them, but many of us were using it for small one-off apps and weren't interested in all of a sudden paying money to send 100 emails a month.

[...] But right when Mandrill announced their pricing change, a new transactional email provider came out of nowhere: SparkPost. [...] So let's walk through the process of signing up and moving Giscus, my app for notifying you of comments on your gists, from Mandrill to SparkPost.

First he walks you through the process of getting a SparkPost account set up and configured to receive messages from your application. He then moves over to the Laravel side, upgrades his installed version and configures it with the "secret" value SparkPost provides and changes the MAIL_DRIVER value - that's basically it.. He also includes some screenshots of other parts of the SparkPost admin interface to show some of the other functionality included.

tagged: tutorial laravel sparkpost service transaction email send

Link: https://mattstauffer.co/blog/using-sparkpost-for-transactional-emails-with-laravel

SitePoint PHP Blog:
What is SparkPost?
Apr 25, 2016 @ 18:50:47

The SitePoint PHP blog has a post to their site introducing SparkPost, an email delivery service (in the same vein as Mandrill) that you can hook into your PHP applications to prevent the need to run your own mail servers.

I’ve used Mandrill for as long as I can remember. It sends transactional email, like the kind you receive when you sign up for a new account. Like me, many have been happy to use a free account for sending a relatively low number of emails a month. That is, until recently, when Mandrill caused a bit of a stir. The heart of the matter is that Mandrill removed their free tier. Anybody wishing to send mail through Mandrill now requires a paid-for MailChimp account

[...] Mindful that people are looking for alternatives (to power their personal newsletters or whatever), I spoke to Aydrian Howard. Aydrian is the Developer Advocate at SparkPost, whom I met at FluentConf. We talked for a bit about SparkPost and what makes it different from MailChimp.

After the little bit of Q&A about the service, the tutorial gets in and shows you how to get SparkPost set up for your application. They help you install their own client library and send a first test email using your account. Code is provided showing the configuration of the client with your key and the options you can define when sending the message.

tagged: sparkpost email send tutorial introduction mandrill

Link: http://www.sitepoint.com/what-is-sparkpost/

Scotch.io:
The Ultimate Guide to Sending Email in Laravel
Apr 01, 2016 @ 17: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


Trending Topics: