Download the PHP package nails/module-email without Composer

On this page you can find all versions of the php package nails/module-email. 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 module-email

Email Module for Nails

license tests

This is the email module for nails, it brings email capability to the app.

The email template

Every email is assembled from three views, concatenated and then run through Mustache in a single pass:

Part Default view
Header email/structure/email_header (_plaintext)
Body whatever the email type declares
Footer email/structure/email_footer (_plaintext)

Body views are bare HTML fragments — a few paragraphs, a table, a button. They inherit the shell and its stylesheet, and should not open a <table> for layout or carry style attributes of their own.

The header and footer are two halves of one document. The header opens everything down to the content well and closes none of it — <html>, <body>, the .body-wrap table and its row, the .container cell, the Outlook ghost table, the .content div, the .main table and its row, and the .content-wrap cell — and the footer closes all nine in order. They are not independently overridable: replacing one means replacing both, and a copy taken today stops tracking upstream changes. Override a slot instead.

The shell

Customising it

Three layers, cheapest first.

1. Do nothing

The masthead calls Logo::discover(), which resolves a logo from the app's composer extra.nails.data.logo_url, then the APP_LOGO_URL config value, then a filesystem probe of assets/img/logo.{png,jpg,gif}. If it finds one you get a branded email header for free; if it does not, the app's name is set as text.

2. Set the content settings in admin

Under Admin → Settings → Email → Content:

Setting Effect
Sign Off A block rendered below the body of every email
Footer Address A postal address in the footer

Both are omitted entirely — no empty row, no stray whitespace — when blank.

Because Mustache runs after the three views have been concatenated, these values share the email's template context. The {{appName}} Team and Hope that helps, {{sentTo.first_name}} both work, as does the {{ config('FOO') }} syntax. They are emitted unescaped, which is the same trust boundary as the email template override admin — treat them as administrator-authored HTML.

3. Override a slot

Drop a file into application/modules/email/views/structure/slots/. It wins over the module's copy through View's normal resolution order; no registration, and no need to touch the shell or its tag-balance contract.

Slot Default
styles nothing — see below
masthead the discovered logo, else the app name as text
greeting Hi {{sentTo.first_name}},, falling back to Hi,
signoff the sign_off setting, else nothing
footer_links view-online and unsubscribe links
footer_address the footer_address setting, else nothing

Each has a <slot>_plaintext counterpart for the text part of the email, which you should override alongside it. Slots receive $emailObject.

slots/styles.php is rendered inside <head> after the module's own <style> block, so anything it emits cascades over the framework. That is the hook for an app which compiles its own email CSS:

There is no CSS inliner in the pipeline, so this has to be an inline <style> block rather than a <link>.

The stylesheet

assets/sass/email.scss is a manifest; the framework itself is a set of partials under assets/sass/email/:

Every partial imports its own dependencies, so any one of them can be compiled on its own. Set your tokens before the import, or the !default wins:

Media-query and dark-mode rules live in the partial they belong to rather than a trailing responsive.scss, so cherry-picking components/button gets the button's narrow-viewport and dark rules with it.

Tokens are Sass variables rather than custom properties, which is a deliberate divergence from nails/common: Outlook renders with the Word engine, which has no var() support and no fallback which can recover a missing colour, so tokens have to compile down to literals. Everything is prefixed $email- because @import leaks globals.

assets/css/email.min.css is a committed build artefact. Run yarn build after changing anything under assets/sass/ and commit the result.

Class reference

Everything below is available to a body view.

Alerts — alert plus one of alert-success, alert-info, alert-warning, alert-danger. alert--success and friends work too.

Banners — alert alert-header is the subject banner and alert-header--warning / --danger / --success / --info are solid-fill bands. These belong to the shell; a body view rarely wants them.

Buttons — btn (or button) plus one of btn-primary, btn-secondary, btn-default, btn-success, btn-warning, btn-danger, btn-info, btn-link. Add btn-block for full width. btn--primary-style modifiers and the button-* aliases work as well.

A button fakes its padding with a border, because Outlook ignores padding on an anchor. The consequence, if you are writing a variant of your own: the padding ring is painted with the border colour, so border-color has to equal the fill. An outline variant draws its rule with a non-inset box-shadow.

For a single, important call to action, btn-table is the Outlook-hardened version — a one-cell table, so the whole area is clickable everywhere:

Tables — table, with table--list for a two-column label/value list, table--numeric to centre every column after the first, and table--plain for no borders or tints. Do not put role="presentation" on a data table.

Panel — panel with panel__header, panel__body and panel__footer. Works as a <div> or a single-column <table>. panel--plain sits on the card rather than being tinted by it; panel--brand adds a brand rule.

Other components — badge (badge--neutral, --success, --warning, --danger, --info), divider (--tight, --loose, --strong, --blank), hero with hero__caption, code / <pre> for monospaced output, and heads-up for a value the recipient has to read off the screen and use.

Utilities — alignleft / aligncenter / alignright and their text-left / -center / -right equivalents; text-muted, text-brand, text-small, text-tiny, text-large, text-bold, text-normal, text-uppercase, text-nowrap, text-break; valign-top / -middle / -bottom; mobile-only and desktop-only; last to drop a trailing margin; and spacing steps on a 4px scale — m-0 … m-7, mt-, mr-, mb-, ml-, mx-, my- and the p- equivalents (0, 4px, 8px, 12px, 16px, 24px, 32px, 48px).

Preheader — the snippet a client shows next to the subject in the message list. Set preheader in the email's data to fill it.

Client caveats

Previewing and testing

In a development environment the view online link in the footer renders the email debugger, which shows the Mustache context, the HTML part in an <iframe> and the plain text part side by side.

The HTML pane has a System / Light / Dark switcher. System is the default and renders the email untouched, so it follows your desktop appearance and is the only pane that exercises the real prefers-color-scheme query. Light and Dark render copies with that query rewritten to always or never match, which is what lets you see both palettes without changing your OS appearance or reaching for DevTools. The pane is 680px wide so the 600px card previews its desktop layout; narrow the window to fall below the 640px breakpoint and see the mobile one.

The dark panes show what Apple Mail, Mail on iOS and Outlook.com do. They say nothing about Gmail — see the dark mode note under Client caveats.

To send real mail:

Admin → Utilities → Send test email does the same through the UI.


All versions of module-email with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
nailsapp/common Version dev-master
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 nails/module-email contains the following files

Loading the files please wait ...