dwolke/zf-mailer

Simple Mailer for Zend Framework 3

1.0 2019-09-04 08:37 UTC

This package is auto-updated.

Last update: 2024-11-05 03:40:44 UTC


README

Simple Mailer for the Zend Framework v3

Latest Stable Version Latest Unstable Version License Build Status Code Coverage

WARNING: This module is currently under heavy development and is not intended for use in productive environment.

Introduction

ZfMailer is a simple e-mail module for Zend Framework 3 based on Zend\Mail. E-mails can be sent in text format or as MIME-compliant "multi-part" mails. Sending e-mails with attachments is also supported.

Currently, only sending e-mails by SMTP is supported. Maybe this module will be extended later with further possibilities.

Installation

Main Setup

  1. Add this module to your project by running the command
$ composer require dwolke/zf-mailer

Post Installation

After installation with composer, add the module to your application.config.php.

<?php

return array(
  'modules' => array(
    // ...
    'ZfMailer',
    // ...
  ),
  // ...
);

Settings

Copy the configuration file from vendor/dwolke/zf-mailer/config/zfmailer.local.php.dist to config/autoload/zfmailer.local.php and change the values as desired.

Options

The following options are available:

  • smart_host [array] - configures the server that sends the mails
    • server_name [string] - servers hostname
    • server_port [string] - tcp port, default is 25
    • username [string] - username for connection to the server
    • password [string] - password for connection to the server
  • encoding [string, optional] - default is 'UTF-8'
  • default_from [string, optional] - This e-mail address for the sender will be used if no sender address is specified when sending an e-mail.
  • return_path [string, optional] - Address to which bounces are sent
  • reply_to [string, optional] - Address to which replys are sent.
  • x_mailer [string, optinal] - Adds the 'X-Mailer' header to an e-mail
  • organization [string, optional] - Adds the 'Organization' header to an e-mail

Usage

Using the mailer is quite simple.

// get the service
$mailer = $serviceManager->get('ZfMailer\Service\Mailer');

// create a new mail
$mailer->createNewMail($recipient, $subject, $sender);

// set the content and render the e-mail body
$mailer->prepareAsMultipart($mailContent, $textTemplate, $htmlTemplate);

// send the e-mail
$mailer->sendEmail();

That's all.

Copyright © 2012 - 2019 by dwLabs. Alle Rechte vorbehalten. 😎