News Feed

News Archive
feed this:

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

SitePoint PHP Blog:
Sending Emails in PHP with PHPMailer
April 27, 2015 @ 12:53:56

The SitePoint PHP blog has a tutorial from Narayan Prusty showing you how to effectively use PHPMailer to send emails from your PHP application. PHPMailer provides a simplified interface to send both simple and complex emails.

PHPMailer is one of the most popular open source PHP libraries to send emails with. It was first released way back in 2001 and since then it has become a PHP developer's favorite way of sending emails programmatically, aside from a few other fan favorites like Swiftmailer. In this article we'll talk about why you should use PHPMailer instead of PHP's mail() function and we'll show some code samples on how to use this library.

He starts by answering the obvious question - is it an alternative to PHP's own mail function? He describes the differences, mostly in the way of enhanced functionality PHPMailer offers. He then helps you get it installed via Composer and how to send a first simple email. Next up he shows how to send an email with attachments and connecting the library to an external SMTP server for sending. The tutorial finishes with a quick mention of using POP3 to read emails and how to show local error messages when something goes wrong.

0 comments voice your opinion now!
tutorial send email phpmailer library simple attachment smtp pop3 error


Phillip Shipley:
Creating a PHP Nexmo API Client using Guzzle Web Service Client - Part 2
April 09, 2015 @ 11:58:38

Phillip Shipley has posted the second part of his series (first part is here) about creating a PHP client for the Nexmo API with Guzzle, the popular PHP HTTP client.

In Part 1 of this series we laid a foundation for consuming the Nexmo SMS API and covered a few ways to interact with it. In this part we'll create the actual Guzzle Web Service Client to interact with it to demonstrate how simple it can be.

He starts by getting Guzzle installed via Composer including a few extra components: guzzle-services, retry-subscriber and log-subscriber. He defines the structure (code) for the message to send to the Nexmo service. Next up is the creation of the actual client that takes in configuration settings and extracts the HTTP location and applies the provided credentials to the connection. Finally he makes a simple SMS client that extends this base client and puts it to use with a simple message defined in an array (to, from and text contents). The client then reports back the results in a simple nested array with response information from the Nexmo API.

0 comments voice your opinion now!
nexmo client guzzle webservice api part2 series connect send


Rob Allen:
Sending attachments in multipart emails with ZendMail
September 16, 2014 @ 09:18:09

Rob Allen has a new post today showing you how to use the ZendMail component of the Zend Framework 2 to send attachments with multipart emails. A multipart email allows you to combine both the HTML and plain text versions of the content into a single email.

I've written before about how to send an HTML email with a text alternative in ZendMail, but recently needed to send an attachment with my multipart email. With help from various sources on the Internet, this is how to do it.

He includes the full code for the example first: a "sendEmail" function that sets up the MIME and plain-text parts and uses the "MimeMessage" and "MimePart" objects to attach the file. He goes through each of the parts of the script and describes what's happening and how that changes the content of the email. You can find out more about the ZendMail component in this section on the Zend Framework manual.

0 comments voice your opinion now!
tutorial send email attachment multipart zendframework2 zendmail

Testing Emails in PHP. Part 1 PHPUnit
December 18, 2013 @ 13:04:05

On an tutorial has been posted showing you how to use PHPUnit to test emails - verifying that your application emails are being sent with the help of a third-party service.

So how do you check that your applications sends email correctly? It looks like dealing with emails is always a challenge. How would you verify that email message is formatted and delivered correctly, without actually sending them to your clients? That's the first question. And the second question is: how can we automate testing of emails? For both questions we have an answer.

To answer the first, they recommend using a service like Mailtrap or Mailcatcher (the one they use for the post) to receive the emails for evaluation. They help you get both PHPUnit and the popular Guzzle HTTP library installed to help with resting against Mailcatcher's REST API. The example test is also included, showing a few methods that connect to the API, get the most recent messages and clear the list when it's complete. Assertions like assertEmailIsSent, assertEmailHtmlContains and assertEmailSenderEquals show how to test the message results that come back for validity.

0 comments voice your opinion now!
test unittest phpunit email send mailcatcher rest api

Sending Emails With Laravel 4 & Gmail
December 18, 2013 @ 11:57:25 has posted a new tutorial today showing you how to use Laravel 4 and Gmail together to send emails from your application. It uses Laravel's own mail functionality, so there's no additional libraries to download.

Sending emails is crucial for any web application. Usually, an email is sent to notify the user of some kind of activity that has taken place on the site, for example, such as when updates have been made or when new friends have been found. In this short tutorial, I'll show you how to send emails with Gmail quickly from within a Laravel sample application by extending the functionality that we built in my last tutorial, Authentication With Laravel 4.

They show you how to set up the mail configuration to correctly point to the Gmail STMP servers using your own Gmail username/password (or one you've set up for the application). Some sample code is included showing how to send an email once the user has registered. Also included is an example of using Laravel's own templating to build the contents of the email.

0 comments voice your opinion now!
send email tutorial gmail laravel template

Sending Mail Using PHP and Amazon SES on Centos/AWS Linux
March 27, 2013 @ 10:56:53

In this new post to her site Alison shows how to send emails through the Amazon Simple Email Service (SES) from a CentOS instance (an AMI in this case).

If you find yourself using Amazon SES for sending outgoing emails in a PHP web app, getting everything set up is much simpler than it may seem. In my case, this was on an AWS Linux image, but it will work on any Fedora/CentOS AMI. You can, of course, set up sendmail and use a proper MTA to send email from your web app, but in this case, I had inherited the requirement to set up an environment for code that was already written to use SES for outgoing email and Google Apps for incoming emails, so the actual mechanics weren't up for debate.

She includes screenshots showing how to configure the SES system with your site's domains and DNS as well as the email addresses you're planning on using. She links over to the MSMTP software you'll need to install on your instance to make the connection and what you'll need to do to get it configured for PHP's use. A sample email script is also included to test the connection (and where to look to make sure everything worked correctly).

0 comments voice your opinion now!
amazon ami ses email send centos tutorial

Rob Allen:
Sending an HTML with text alternative email with ZendMail
November 02, 2012 @ 10:26:20

Rob Allen has a quick tutorial posted to his site today showing you how to send an email with the ZendMail component of the Zend Framework 2 that contains HTML but provides a plain text backup in the same message.

Sending a multi-part email with ZendMail is easy enough, but if you want to send an HTML email with a text alternative, you need to remember to set the content-type in the headers to multipart/alternative. As this is the second time I had to work this out, I'm noting it here for the next time I forget!

The rest of the post is the code you'll need to send a simple email with a text and HTML body sections, configure the headers (to, from, etc) and the "multipart/alternative" header to make the HTML or plain text switching work correctly.

0 comments voice your opinion now!
zendframework2 mail tutorial send alternative html plaintext

Sebastian Göttschkes:
symfony2 Testing email sending
September 13, 2012 @ 08:52:03

Sebastian Göttschkes has a new post showing a method he's come up with to test email sending in a Symfony2 application.

On my endless struggle to achieving 100% code coverage and catching every possible (and impossible) test case (I'm just kiddinh, please don't do this!) I was in need for some way to test the sending of emails. This blog post will show you how to test this within a symfony2 (I'm using symfony 2.1 RC2) application, using the default swiftmailer.

It's not unit testing, it's functional testing, and he provides a bit of background on the process first then sets up a dummy listener for testing and how to plug in the Symfony2 functionality (via a getContainer call to get the DIC).

0 comments voice your opinion now!
symfony2 swiftmailer testing webtest email send
Implement Two-Way SMS with PHP
July 17, 2012 @ 08:46:22 has an interesting new article posted today showing how you can use PHP to create a two-way messaging (SMS) application that can both send and initiate actions based on message content.

SMS is used for various purposes these days. For example, major websites like Gmail and Facebook use SMS to improve their authentication process with multi-factor authentication and notifying users about the updates. These are one-way SMS applications since messages are sent only from these sites to the user. Two-way SMS applications are more complex than one-way ones. In two-way SMS apps, a user can initiate a conversation by sending messages, and then the application responds according to the user's commands.

They base the application on the Clickatell SMS service (not free, but cheap - pay by the message too) which includes the ability to hook into your API on a specific endpoint and relay the message data. The message can either be sent via a POST or GET and can easily be interpreted in your app extracting things like a timestamp, the number it came from and, of course, the actual text of the message. There's also a section about the "User Data Header" functionality that lets you easily split up a message for recombination on the remote device. Code is included for all examples.

0 comments voice your opinion now!
sms tutorial bidirectional send receive

Paul Reinheimer's Blog:
Sending Mail
May 23, 2012 @ 12:58:29

Paul Reinheimer has posted about his experiences with sending mail, specifically as it relates to using the Zend_Mail component from the Zend Framework to handle the details.

Like every product, Natural Load Testing needs to send some mail, having written and re-written a bunch of different blocks of mail code over the years, I wanted to come up with something that would work now, and continue to serve us well into the future.

He chose Zend_Mail to fulfill some of his requirements (multipart emails, sending custom emails, templates for automatic emails) and includes some sample code showing it at work. The result is an object that can be created and, by calling a "basic" method, can send an email based on an HTML template (using the HTML Email Boilerplate for the base styling).

0 comments voice your opinion now!
send email zendmail tutorial template

Community Events

Don't see your event here?
Let us know!

symfony2 application api voicesoftheelephpant series performance opinion interview extension community library framework release podcast composer version laravel introduction php7 example

All content copyright, 2015 :: - Powered by the Solar PHP Framework