Download the PHP package ikkez/f3-mailer without Composer
On this page you can find all versions of the php package ikkez/f3-mailer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package f3-mailer
Sugar Mailer
This is a little mail plugin that contains:
- SMTP plugin wrapper
- easily send plain text, html or both text & html hybrid content mails
- convenient methods to add one or multiple recipients
- encode special chars for mails with ISO charset
- ping and jump methods for tracking read and click events in your html mails
- save mails as files to disk
Getting started
This plugin is configurable via config file:
Usage
A little sample looks like this:
If you want, you can change the encoding type that is used for the email body and header when instantiating the mail object with a constructor argument:
Tracking
To initialize the tracking routes, call this before $f3->run()
:
To add the ping tracking pixel (1x1 transparent 8bit PNG), put this in your html mail body:
The file name should be a unique hash you can use to identify the recipient who read your mail.
The tracking methods could look like this:
Mock & Storage
In case you don't want to actually send the email, but just want to run a test flight and save the mail in a text file, you can mock the server dialog:
If you want to keep using the object after a mock call, you need to reset the mailer and add recipients, content and attachments again.
The mail file includes all file attachments.
Logging
You can log the full SMTP server dialog after sending the email. This could be useful for debugging purposes or as a sending confirmation.
Notice: By default, the log level is verbose
, which means it also contains the mail body and attachments, which might eat up a lot of memory.
To reduce the log level, set $log
to TRUE
(dialog only) or FALSE
(disabled) in:
Keep in mind that when you write down mails to files, it can only store what was found in the SMTP log, hence it only works when logging level is verbose
.
Demo & Testing
There's a test bench available here: https://github.com/ikkez/f3-mailer/tree/test
API
addBcc
Adds a blind carbon copy recipient.
addBcc($email, $title=null)
addCc
Adds a carbon copy recipient.
addCc($email, $title=null)
addTo
Adds a direct recipient.
addTo($email, $title=null)
attachFile
Adds a file attachment.
attachFile($path, $alias=null, $cid=null)
initSMTP
Initializes SMTP plugin. Useful if you want to reuse the Mailer object but with a fresh SMTP adapter beneath. It's possible to change options before, i.e. to use a different smtp server.
initTracking
This registers the required routes to F3
log
Returns SMTP log
reset
Reset recipients if key was given, or restart whole smtp plugin.
($key=null)
save
Save the send mail to disk
save($filename)
send
Send message
send($subject [, $mock = false [, $log = 'verbose']])
log level options: FALSE
, TRUE
, 'verbose'
set
Set encoded header value
set($key, $val)
setContent
Set message contents by mime type
setContent($data [, $mime [, $charset=NULL ]])
I.e. for AMP mails:
$mailer->setContent($amp,'text/x-amp-html');
setErrors
Set receipient for bounce error mails
setErrors($email [, $title=null])
setFrom
Set message sender
setFrom($email [, $title=null])
setHTML
set message in HTML text format
setHTML($message)
setReply
set reply-to field respected by most email clients
setReply($email [, $title=null])
setText
set message in plain text format
setText($message)
License
You are allowed to use this plugin under the terms of the GNU General Public License version 3 or later.
Copyright (C) 2022 Christian Knuth [ikkez]