Download the PHP package studosi/mail-filter without Composer

On this page you can find all versions of the php package studosi/mail-filter. 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 mail-filter

Mail Filter

Mail Filter extension for Flarum - filter e-mail registering by your sites with whitelists, blacklists and regular expression describing both.

License Latest Stable Version


Requirements

This extension was built and tested on Flarum 0.1.0-beta12 and PHP7.4. If you are having issues and a different build, please mention that you didn't use the same setup as this (so I know to test it on another environment).

Other than that, there are no prerequisites. It's really a minimal extension.


Installation

Use Bazaar or install manually with composer:


Updating


Screenshots


Links


How to use

In the admin panel, there are 4 categories of settings:

Using these settings categories, you can introduce various constraints on who can register for the site - in further text, we'll call these constraints rules.

Whitelist and blacklist

Rules in this category will be explicitly checked if they are the same (using the == operator in PHP).

Regular expression constraints

Rules in this category will be matched using preg_match.

Also, the browser will check if the regular expressions themselves are valid. I am not so well informed on the compatibility between JavaScript's and PHP's regex engines, so this validity check might not work as expected: in that case, submit an Issue.

Basically, these checks check the whole string. This is so you can potentially block certain user names, and not only domains.

Also, one last thing, this takes in regular expressions - languages specific things like prepending and appending a / to a string like in PHP is no necessary (in fact, this extension does it by default, without checking if such a thing already exists).

Example of good regular expression practices

I'll comment in short about some good practices when creating regular expression constraints for e-mails.

Domain limitations

For an example, if you want to filter out gmail emails, you'd introduce a regular expression that goes something like

There are a few things to note here.

First of all, you introduce a particle that goes something like [^\@]*. This will ensure that you cover any subdomain. This kind of expression is good for a blacklist (since it is strict).

The second thing to note is the terminated . - this is important to note for beginners because the . is actually an any-character alias in most if not all regex engines, and without a terminator (what we call the \) it can match things like gmailacom, gmaillcom etc. (note the different characters between gmail and com)

The last thing to note is the end-of-string operator ($). You should use it when matching domains since it reduces overhead and is punctual since domains are the last part of an email.

If you're creating expressions for a whitelist, you should use expressions that cover less domains, i.e.

This is also strict because it will only allow mails that end in @gmail.com to pass through, but not any subdomains of the gmail.com domain you might not know how to handle otherwise.

Username limitations

Let's say you want to filter out e-mail that starts with mark. Doing so is fairly trivial:

Note again that I'm using a [^\@]* pattern. Also, note that I marked the beginning of an entry with ^. Without that, the regex engine would search the whole string for a match, which is not something you want.

But for an example, let's say you wanted to filter out e-mails that contain the word fuck in them (disregarding where). Then you could just make an entry equal to

or

which will be case-insensitive (although e-mails, which are URIs, are case insensitive, although I'm not sure if they're normalized by Flarum, would have to check).


Names

Names do not have to be unique - they're used for micro-categorizations and will likely be searchable in the future. Also, they are required by default, not for any functional reason, but for your good. People forget things :)


Activity

Every rule can be activated and deactivated without erasing them. This is done by using the switch left of the rule definition. When the server check if an e-mail is valid, checks for these rules will be skipped.


Order of execution

As of now, the extension will run this:

In other words, the priority chain is illustrated with this:

Of course, other priority chains are possible (ex. whitelist > blacklist > whitelist regular expression > blacklist regular expression), and this might be a setting in a future release.

Currently, if the mail passes through the check, the function called validate() will return 0, i.e. it uses C-esque returns. In the future there might be error codes added to the whole thing and exception throws might be completely moved to the extend.php file.


Roadmap


About

This plugin was originally written by Yalfoosh. It is a part of the Studoši community - a Croatian education forum run by academic citizens.

If you like it, give it a star :)

All Flarum open source projects by us will have the Apache 2.0 license.

If this is not the case, or you have any other questions or inquiries, make sure to contact us at semi-business e-mail.


All versions of mail-filter with dependencies

PHP Build Version
Package Version
Requires flarum/core Version ^0.1.0-beta.8
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 studosi/mail-filter contains the following files

Loading the files please wait ....