Download the PHP package creativecrafts/php-aws-send-email without Composer

On this page you can find all versions of the php package creativecrafts/php-aws-send-email. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-aws-send-email

PHP AWS Send Email

Latest Version on Packagist Tests Total Downloads

A powerful and flexible PHP package for sending emails via Amazon SES (Simple Email Service) with advanced features including templating, attachments, logging, and rate limiting. This package is designed to simplify email operations while providing robust controls and customization options.

Features

These features cater to a wide range of email sending needs, from simple transactional emails to complex, templated marketing campaigns with attachments.

Installation

You can install the package via Composer:

Ensure you have Composer installed on your system before running this command. This package requires PHP 8.2 or higher.

Usage

Basic Usage

The EmailService class is the core of this package, providing a simple interface to send emails via Amazon SES.

Use this for sending transactional emails, notifications, or any automated email communication. Remember to handle exceptions that might occur during the sending process.

Using Optional Features

This package offers additional features to enhance your email sending capabilities. By leveraging a logger, rate limiter, and template engine, you can create a more robust and flexible email service.

By incorporating these optional features, you can log email activities, control sending rates, and use templates for consistent and dynamic email content. This approach is particularly useful for applications that send a high volume of emails or require detailed tracking and control over the email sending process.

Advanced Usage

The EmailService class provides advanced features to handle more complex email sending scenarios. Here are some examples of how you can leverage these capabilities:

Sending Emails with Attachments

You can easily add file attachments to your emails using the addAttachment method. This is useful for sending documents, images, or any other files along with your email content. To send emails with multiple attachments seamlessly, follow these steps:

  1. Initialize the EmailService with Optional Features:

  2. Prepare the Email Data and Add Attachments:

  3. Send the Email:

This feature is particularly helpful when you need to send invoices, reports, or supplementary materials along with your emails. You can add multiple attachments by calling this method multiple times.

Asynchronous Sending

For applications that need to handle high volumes of emails without blocking the main execution thread, the sendEmailAsync method provides an asynchronous approach to email sending.

Asynchronous sending is beneficial in scenarios where you're sending multiple emails simultaneously or when you want to improve the performance of your application by not waiting for the email to be sent before continuing execution. This method returns a promise, allowing you to handle the success or failure of the email sending operation in a non-blocking manner.

Using Templates with Attachments

Combine templating and attachments to send personalized emails with supplementary files.

Using Templates

Templates allow you to create reusable email content, making it easier to maintain consistent messaging across your application. This package supports two types of templates: Simple and Advanced.

Simple Templates

Simple templates are best for straightforward, text-based emails with basic variable substitution.

Example Simple Template (welcome.phtml):

Use simple templates for welcome emails, password reset notifications, or any email where the content structure remains largely the same with only a few changing variables.

Advanced Template

Advanced templates offer more flexibility, allowing you to use PHP in your templates for complex logic and data manipulation.

Example Advanced Template (order_confirmation.phtml):

Advanced templates are ideal for emails that require conditional content, loops, or complex data presentation. They're great for personalized newsletters, detailed reports, or any email where the content structure might vary significantly based on the data.

Template Engines

Template engines provide a way to manage and render multiple templates efficiently. This package includes two template engines: SimpleTemplateEngine and AdvancedTemplateEngine.

Advanced Template Engine

The AdvancedTemplateEngine allows you to:

Using Partial Rendering and Shared Variables

Shared variables (like color codes) are defined once and made available across all templates and partials. This ensures consistency and reduces redundancy.

Shared Variables (snipplet-email-variables.php):

Including Partial Templates:

Partial Template (snipplet-email-header.phtml):

This setup ensures that all templates and partials have access to the shared color variables without the need for including external files, enhancing security and maintainability.

Simple Template Engine

The Simple Template Engine is perfect for managing multiple simple templates.

Use this when you have multiple simple email templates and want to keep them organized in separate files. It's great for managing a suite of transactional email templates.

Usage with EmailService

Now, let's create an example of a simple template that this code might use:

The SimpleTemplateEngine will replace the placeholders in curly braces with the corresponding values from the $emailData array.

Logging

Logging is crucial for tracking email operations, troubleshooting, and maintaining an audit trail.

Example Logger Implementation:

Using the Logger with EmailService:

Use logging to keep track of successful sends, failures, and other important events in your email operations. This can be invaluable for debugging and monitoring your application's email functionality.

Rate Limiting

Rate limiting helps you control the volume of emails sent, ensuring you stay within Amazon SES limits and avoid overwhelming recipients.

In-Memory Rate Limiter

Suitable for single-server setups or applications with low to moderate email volume.

Use this for smaller applications or when you don't need to share rate limit data across multiple servers. Be aware that the limits reset if your application restarts.

Redis Rate Limiter

Ideal for distributed systems or high-volume applications that require persistent and shared rate limiting.

The RedisRateLimiter offers several advantages over the InMemoryRateLimiter:

  1. Persistence: The rate limit data is stored in Redis, so it persists even if your application restarts.
  2. Distributed: If you have multiple application servers, they can all share the same rate limit by connecting to the same Redis instance.
  3. Scalability: Redis is designed to handle high-concurrency scenarios, making it suitable for applications with high email volumes.

When using the RedisRateLimiter, consider the following:

- Ensure your Redis server is properly configured and secured.
- Monitor your Redis server's performance, especially in high-volume scenarios.
- Consider using a dedicated Redis instance for rate limiting to isolate it from other Redis-based operations in your application.
- Implement proper error handling for Redis connection issues.

This setup allows you to maintain consistent rate limiting across multiple application instances or server restarts, making it ideal for larger, distributed applications or those with high email volumes.

Configuration

Proper configuration is key to getting the most out of this package. Here's what to consider for each component:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of php-aws-send-email with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
aws/aws-sdk-php Version ^3.329
guzzlehttp/guzzle Version ^7.8
psr/log Version ^1.1 || ^2.0 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package creativecrafts/php-aws-send-email contains the following files

Loading the files please wait ....