All Projects → ikkez → f3-mailer

ikkez / f3-mailer

Licence: GPL-3.0 license
Fat-Free Sugar Mailer Plugin

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to f3-mailer

Mailinabox
Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.
Stars: ✭ 10,649 (+59061.11%)
Mutual labels:  mail, smtp
Neomutt
✉️ Teaching an Old Dog New Tricks -- IRC: #neomutt on irc.libera.chat
Stars: ✭ 2,343 (+12916.67%)
Mutual labels:  mail, smtp
Postal
✉️ A fully featured open source mail delivery platform for incoming & outgoing e-mail
Stars: ✭ 11,148 (+61833.33%)
Mutual labels:  mail, smtp
Hedwig
Send email to any SMTP server like a boss, in Swift and cross-platform
Stars: ✭ 1,096 (+5988.89%)
Mutual labels:  mail, smtp
Tmail
Golang SMTP server
Stars: ✭ 251 (+1294.44%)
Mutual labels:  mail, smtp
Mailmergelib
MailMergeLib is a mail message client library which provides comfortable mail merge capabilities for text, inline images and attachments, as well as good throughput and fault tolerance for sending mail messages.
Stars: ✭ 97 (+438.89%)
Mutual labels:  mail, smtp
Docker Postfix
Simple SMTP server / postfix null relay host for your Docker and Kubernetes containers. Based on Alpine Linux.
Stars: ✭ 163 (+805.56%)
Mutual labels:  mail, smtp
Docker Mailserver
Production-ready fullstack but simple mail server (SMTP, IMAP, LDAP, Antispam, Antivirus, etc.) running inside a container.
Stars: ✭ 8,115 (+44983.33%)
Mutual labels:  mail, smtp
Mailu
Insular email distribution - mail server as Docker images
Stars: ✭ 3,151 (+17405.56%)
Mutual labels:  mail, smtp
Maddy
✉️ Composable all-in-one mail server.
Stars: ✭ 2,800 (+15455.56%)
Mutual labels:  mail, smtp
enough mail
IMAP, POP3 and SMTP clients for Dart developers. Contains both low level as well as a high level API.
Stars: ✭ 78 (+333.33%)
Mutual labels:  mail, smtp
imail
small mail server
Stars: ✭ 88 (+388.89%)
Mutual labels:  mail, smtp
Mailer
A lightweight PHP SMTP mail sender
Stars: ✭ 53 (+194.44%)
Mutual labels:  mail, smtp
MailDemon
Smtp server for mass emailing, managing email lists and more. Built on .NET Core. Linux, MAC and Windows compatible.
Stars: ✭ 113 (+527.78%)
Mutual labels:  mail, smtp
Sendria
Sendria (formerly MailTrap) is a SMTP server designed to run in your dev/test environment, that is designed to catch any email you or your application is sending, and display it in a web interface instead of sending to real world.
Stars: ✭ 30 (+66.67%)
Mutual labels:  mail, smtp
Free Email Forwarding
The best free email forwarding for custom domains. Visit our website to get started (SMTP server)
Stars: ✭ 2,024 (+11144.44%)
Mutual labels:  mail, smtp
Inbucket
Disposable webmail server (similar to Mailinator) with built in SMTP, POP3, RESTful servers; no DB required.
Stars: ✭ 685 (+3705.56%)
Mutual labels:  mail, smtp
Mailslurper
Local, web-based mail server application. Slurp mails into oblivion!
Stars: ✭ 920 (+5011.11%)
Mutual labels:  mail, smtp
Ptorx
📩🛡 Email privacy. Anonymously send and receive with alias forwarding.
Stars: ✭ 187 (+938.89%)
Mutual labels:  mail, smtp
rb-sisimai
Mail Analyzing Interface for email bounce: A Ruby library to parse RFC5322 bounce mails and generating structured data as JSON from parsed results. Ruby version of Sisimai: an error mail analyzer.
Stars: ✭ 78 (+333.33%)
Mutual labels:  mail, smtp

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:

[mailer]
; smtp config
smtp.host = smtp.domain.com
smtp.port = 25
smtp.user = [email protected]
smtp.pw = 123456789!
; scheme could be SSL or TLS
smtp.scheme =

; optional mail settings
from_mail = [email protected]
from_name = Mario Bros.
; mail to receive bounced mails
errors_to = [email protected]
; used mail for replies to the sent mail
reply_to = [email protected]

; handler for SMTP errors
on.failure = \Controller\Mail::logError
; handler for tracing opened mails
on.ping = \Controller\Mail::traceMail
; handler for redirecting jump links
on.jump = \Controller\Mail::traceClick
; automatically create jump links in all <a> tags
jumplinks = true
; path for storing mail dumps
storage_path = logs/mail/

Usage

A little sample looks like this:

function send_test($email, $title=null) {
	$mail = new \Mailer();
	$mail->addTo($email, $title);
	$mail->setText('This is a Test.');
	$mail->setHTML('This is a <b>Test</b>.');
	$mail->send('Test Mail Subject');
}

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:

$mail = new \Mailer('UTF-8'); // default
$mail = new \Mailer('ISO-8859-1');
$mail = new \Mailer('ISO-8859-15');

Tracking

To initialize the tracking routes, call this before $f3->run():

$f3->config('mailer_config.ini');
// ...
Mailer::initTracking();
// ...
$f3->run();

To add the ping tracking pixel (1x1 transparent 8bit PNG), put this in your html mail body:

<img src="http://mydomain.com/mailer-ping/AH2cjDWb.png" />

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:

static public function logError($mailer, $log) {
	$logger = new \Log('logs/smtp_'.date('Y_m_d').'.log');
	$logger->write($log);
}

static public function traceMail($hash) {
	// your mail $hash is being read
}

static public function traceClick($target) {
	// someone clicked $target link
}

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:

$mail->send($subject, TRUE); // mock call 
$mail->save('newsletter.eml'); // save to file in 'mailer.storage_path' directory
$mail->reset();

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.

$success = $mailer->send($subject);
$f3->write('SMTP_mail.log', $this->mailer->log());

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:

$mailer->send($subject, $mock, $log);

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]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].