Download the PHP package vecode/moritabox-smtp without Composer

On this page you can find all versions of the php package vecode/moritabox-smtp. 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 moritabox-smtp

moritabox-smtp

Overview

SMTP server built with ReactPHP, supports PLAIN, LOGIN and CRAM-MD5 authentication.

An easy way to run a local SMTP server for testing mail implementations.

Requirements

Installation

The easiest way to install it is to use Composer:

Basic usage

Create an SmtpServer instance by passing an authentication callback; then subscribe to the ready, mail and/or error events:

The ready event is fired when the server is initialized and listening, the error event signals ReactPHP's Socket errors.

Finally, the mail event is fired when a complete mail message has been received, with a Mail instance which contains the from address, recipient addresses and all its contents in plain-text form so that you can store it or parse with a MIME message parser (for example by using the mailparse extension).

Note that you can change the listening port (defaults to 8025) from the SmtpServer constructor and also you can specify the fully-qualified domain for the CRAM-MD5 challenge and also set a flag so that the port is bound only locally (that is, allow connections from 127.0.0.1 only).

SSL/TLS is supported only in implicit mode, that is, the connection starts out with a secure handshake. For it to work you will need to enable it and pass the certificate and private key location (if required):

As you can see, the second parameter is an SSL context options listing as defined here.

STARTTLS is not supported due to a ReactPHP limitation.

Authentication

Each of the supported authentication methods require you to provide an authentication callback that will receive the user name and must return the password for that user or false for non-existing users. As you can see, the returned password must be in plain-text, a limitation on the SMTP protocol, so it is advised to encrypt the passwords if you store them (in a database for example).

If you do not provide an authentication callback, it will be disabled, but it is generally not recommended unless you know what you are doing. For example, relay servers don't require authentication but they must validate the recipient address and reject the message if it is not valid.

Validation

You can also validate the sender/recipient (depending on the server's purpose) by means of the setMailCallback and setRecipientCallback methods, both of them take a Closure as argument that in turn receives an $email parameter; just return true to allow the address or false to deny it.

This example uses a pretty simple approach, but you may use a regular expression or any other advanced mechanism to validate it should you like to.

Using PHPMailer to send mail

The most-common use case is testing email sent from other PHP projects, commonly implemented with PHPMailer or similar libraries.

In the following example you can see a basic setup; the most important bit is the authentication parameters (SMTPAuth, Username and Password, the later two will be checked via the authentication callback described in the previous section):

If you have enabled implicit SSL you must also set the SMTPSecure option as follows:

License

MIT licensed

Copyright © 2023 Vecode. All rights reserved.


All versions of moritabox-smtp with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
react/socket Version ^1.13
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 vecode/moritabox-smtp contains the following files

Loading the files please wait ....