Download the PHP package ublaboo/mailing without Composer
On this page you can find all versions of the php package ublaboo/mailing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mailing
Mailing
Extension for Nette Framework: Easy & object-oriented way of sending & logging mails
Mailing extension lets you send/log emails in the object oriented world.
Overview
Downloading Mailing
Mailing is available through composer package ublaboo/mailing:
MailFactory
MailFactory gives you a way to create your mails instances. In the background it sets some parameters, decides whether to log and email or not, tries to find mail template etc.
Mail is the base class you will extend in each of your email cases (classes). In your particular mail class you will set email senders/recipients/cc/.., basepath (if you want to send inline images), attach files, etc. There are also available config parameters (if you have put them in there through config.neon).
You will send it via Mail::send() method.
Create mail class
Once you have registered mailing extension, you can create new mail class and then get MailFactory from DIC to send it:
Example mail template:
Mail templates
Now, there is some convention in directory structure and you should stick to it. It doesn't matter where you put your mails, but the Mail class (which your mails will inherit from) will look for template latte files in <same_directory_as_your_mails_are</templates
. The name of particular template has to be in camel_case naming convention. E.g.:
But that is only a recommendation. You can always change your template file path by Mail::setTemplateFile()
. Eg:
Or from the outside:
No templates
Of course you don't have to send mails with templates, you can just use plaintext mail body. You would do that probably in your mail class:
Configuration
There are some configuration options available like whether to log (or send, or both), where to log, where to find inline images from, etc
Start with registering extension in config.neon:
There are several config options:
Let's discuss each of these options:
do
In this option you may choose between these three directives:
- log means all mails will be just stored on local disk in log directory. All mails are saved in .eml format (with possible images and attachments)
- send will only send all mails, but not log
- both will do both
logDirectory
That one is pretty obvious. Directory, where mail files (.eml
) will be stored.
mailImagesBasePath
This is the path, where Nette\Mail\Message
will look for all images that can be inline embedded in mail.
mails
This array filled with your parameters (probably mail addresses - like recipients, senders, etc) will be available in instance of each of your mail class (read more) so that you can easily set sender and recipient, bcc, cc or whatever you need for particular mail.
E.g.:
Log
By default, MailLogger is logging all sent Mails in log directory in format
All versions of mailing with dependencies
nette/utils Version ~2.4 || ~3.0
nette/di Version ~2.4 || ~3.0
nette/application Version ~2.4 || ~3.0
nette/mail Version ~2.4 || ~3.0
latte/latte Version ~2.4 || ~3.0